Home | 문태준 | 시스템어드민 메일링 | Sys Admin 세미나

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
$dn = "OU=Users,DC=MYDOMAIN";
$ad = ldap_connect("ldap://SERVER.MYDOMAIN")
      or die("Couldn't connect to AD!");
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
$bd = ldap_bind($ad,$USER_ID,$PWD)
      or die("Couldn't bind to AD!");
$filter = "samaccountname=SOMEREALUSERNAME"; //real user name
$result = ldap_search($ad, $dn,$filter);
$name = ldap_get_values($ad, $entry, "samaccountname");

print "hours: ".$hourshex."<br>"; 



검색방법이 좀 다르기에 추가 정보를 입력한다.
for 과 ldap_next_entry 를 이용하여 전체 데이터를 처리하면 될 것이다.


Code Block
Here's a nice way to user ldap_first_entry,ldap_next_entry.

$res = ldap_search($ldapc,$searchroot,$filter,$attributes);
for ($entryID=ldap_first_entry($ldapc,$res);
// Do stuff with the $entryID.
$values = ldap_get_values($ldapc,$entryID,'uid');