note 38289 added to ref.com
| From: | kleontiv-at-combellga-dot-ru at rn2 dot php dot net | Date: | Mon, 15 Dec 2003 16:47:34 +0000 |
| Subject: | note 38289 added to ref.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-61992@lists.php.net to get a copy of this message | ||
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) ;
?>
----
Manual Page -- http://www.php.net/manual/en/ref.com.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38289
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38289&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38289&report=yes
Search -- http://master.php.net/manage/user-notes.php