You are here: Re: PHP and Active Directory « PHP Programming Language « IT news, forums, messages
Re: PHP and Active Directory

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация