note 29444 rejected from ref.ldap by nicos
| From: | nicos@php.net | Date: | Thu, 13 Feb 2003 21:30:41 +0000 |
| Subject: | note 29444 rejected from ref.ldap by nicos | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43896@lists.php.net to get a copy of this message | ||
Hi, I use php4.3.0_win32 to connect to W2k Active Directory using IIS5.0. I use the following code:
****************
$server = "ldap://<servername>";
$connect = ldap_connect($server);
$basedn ='DC=int,DC=ca,DC=pason,DC=com';
$upn =$login."@int.ca.pason.com";
// $login is the sAMAccountName
$pass ="$password";
// $password is the password used to log on to the workstation.
$justthese = array('ou');
$expression="(sAMAccountName=$login)";
if (!$connect) {
die ("Could not connect to $server");
}
else{
$bind = @ldap_bind($connect, $upn, $pass);
if ( $bind ) {
$sr = ldap_search($connect, $basedn, $expression,$justthese, 0, 250, 30);
if(!$sr) {
echo "Unable to search.";
echo ldap_error($connect);
}
$info = ldap_get_entries($connect, $sr);
$number_returned = count($info);
for ( $i = 0; $i<$number_returned; $i++) {
print "The department is ".$info[$i]['ou'][0];
}
}
else{
die ("Could not binding $user by $pass.");
}
}
ldap_close($connect);
**********************
When I run it no error for connect and bind.But always have the error:
Warning: ldap_search(): Search: Can't contact LDAP server in
c:\inetpub\wwwroot\webPortalForms\dblib.inc on line 339
Anyone can help me out? Thanks.