note 63909 added to function.ldap-search
| From: | buhreen at shaw dot ca | Date: | Mon, 03 Apr 2006 16:12:46 +0000 |
| Subject: | note 63909 added to function.ldap-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107234@lists.php.net to get a copy of this message | ||
If you are just trying to run LDAP searches against Active Directory, you might find it easier to
use the COM objects and use the ADSI ldap search function. This allows you to use SQL based LDAP
queries. It also allows you to perform subtree level searches in AD.
Here is a quick example.
<?php
$Conn = New COM("ADODB.Connection");
$RS = New COM("ADODB.Recordset");
$Conn->Provider = "ADsDSOObject";
$Conn->Properties['User ID'] =
"CN=ZimZam,CN=Users,DC=corp,DC=ad,DC=bob,DC=prv";
$Conn->Properties['Password'] = "anythingyouwant";
$strConn = "Active Directory Provider";
$Conn->Open($strConn);
$strRS = "Select givenname,sn,displayName,mail,SAMAccountName from
'LDAP://corp.ad.bob.prv/DC=corp,DC=ad,DC=bob,DC=prv' where objectClass='user'
and SAMAccountName='abc123';
$RS->Open($strRS, $Conn, 1, 1);
echo $RS['givenname'] ." - ". $RS['sn'] ." - ".
$RS['displayName'] ." - ". $RS['mail'] ." - ".
$RS['SAMAccountName'] ."<br>";
$RS->Close;
$Conn->Close;
?>
----
Server IP: 66.207.199.35
Probable Submitter: 207.229.3.97 (proxied: 1.0 ASCUCBASX_01)
----
X-Spam-Status: No, hits=4.0 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE,UPPERCASE_25_50 autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.ldap-search.php
Edit -- http://master.php.net/note/edit/63909
Del: integrated -- http://master.php.net/note/delete/63909/integrated
Del: useless -- http://master.php.net/note/delete/63909/useless
Del: bad code -- http://master.php.net/note/delete/63909/bad+code
Del: spam -- http://master.php.net/note/delete/63909/spam
Del: non-english -- http://master.php.net/note/delete/63909/non-english
Del: in docs -- http://master.php.net/note/delete/63909/in+docs
Del: other reasons-- http://master.php.net/note/delete/63909
Reject -- http://master.php.net/note/reject/63909
Search -- http://master.php.net/manage/user-notes.php