note 38289 deleted from ref.com by cmb

From: Date: Sun, 30 Jun 2019 07:47:07 +0000
Subject: note 38289 deleted from ref.com by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211416@lists.php.net to get a copy of this message
Note Submitter: kleontiv -at- combellga -dot- ru ---- And here is an example of using ADSI via ADODB. This sample is unique because only ADODB can provide recursive Active directory searching and listing. But ADODB can only READ Active directory. So you can find something by ADODB and then modify that directly by ADSI. With previos example this help build you PHP coded interface to Menaging and browsing Microsoft Active Directory. Also ADODB on ADSI helps you sort recordset and search on it. <?php $objConnection = new COM ("ADODB.Connection") ; $objConnection->Open("Provider=ADsDSOObject;user id=DOMAIN\\login;password=your_passowrd;") ; $objCommand = new COM("ADODB.Command") ; $objCommand->ActiveConnection = $objConnection ; $Cmd = "<LDAP://dc=mydomain,dc=com>;" ; $Cmd .= "(&(objectClass=user)(mail=*)(!cn=SystemMailbox*));" ; $Cmd .= "name,mail,telephoneNumber;subtree" ; $objCommand->Properties['Sort On']->Value = "name" ; $objCommand->CommandText = $Cmd ; $objRecordSet = $objCommand->Execute() ; $OrderNumber = 0 ; while(!$objRecordSet->EOF()) { $OrderNumber ++ ; $nn = $objRecordSet->Fields['name']->Value ; $mm = $objRecordSet->Fields['mail']->Value ; $ph = $objRecordSet->Fields['telephoneNumber']->Value ; echo "$OrderNumber: $nn mail: $mm phone: $ph<br>" ; $objRecordSet->MoveNext() ; } Echo "===========================<br>" ; Echo "All MailBoxes: " ; Echo $objRecordSet->RecordCount() ; $objRecordSet->Close() ; $objCommand->Close() ; $objConnection->Close() ; unset($objRecordSet) ; unset($objCommand) ; unset($objConnection) ; ?>

« previous php.notes (#211416) next »