|
Posted by Sacs on 09/16/05 01:29
Replying to myself, bad form I know, but bug in my code (I had taken it
from some notes, not actual working code...)
<?php
$ldap_def_user = "cn=ldapquery,ou=Users,dc=yourcompany,dc=com";
$ldap_def_pass = "password";
$ldap_server = "server.yourcompany.com";
$ldap_base_dn = "ou=Users,dc=yourcompany,dc=com";
$Connect = ldap_connect($ldap_server) or die("Could not connect") ;
$Bind = ldap_bind($Connect,$ldap_def_user,$ldap_def_pass) or die("Could
not bind");
$UserName=JoeUser;
$ld_filter = '(sAMAccountName=' . $UserName . ')';
$ld_data = array('dn');
$ld_sr = ldap_search($Connect, $ldap_base_dn, $ld_filter, $ld_data);
$ld_info = ldap_get_entries($Connect, $ld_sr);
$ld_count = $ld_info['count'];
if ( $ld_count < 1) {
print("User $UserName doesn't exist");
} else {
$ldap_user_dn = $ld_info[0]['dn'];
print("$UserName DN is $ldap_user_dn");
}
?>
Navigation:
[Reply to this message]
|