http://www.stunnel.org/ $AD_Auth_User = "account@domain"; //Administrative user $AD_Auth_PWD = "password"; //The password $dn = 'CN=Users,DC=domain'; //CONNNECT TO AD $ds = ldap_connect('ldaps://'.$AD_server); if ($ds) { //Using LDAPv3 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); //Mmaximum number of entries that can be returned on a search operation ldap_set_option($ds, LDAP_OPT_SIZELIMIT, 35000); //Bind to AD Server $r = ldap_bind($ds, $AD_Auth_User, $AD_Auth_PWD); $dn = "CN=Users,DC=domain"; //Search CN All User $filter="(|(cn=*))"; $need_attribute = array( "ou", "sn", "givenname", "mail"); $sr=ldap_search($ds, $dn, $filter, $need_attribute); /*$sr=ldap_search (ilter [, array $attributes [, int $attrsonly [, int $sizelimit [, int $timelimit [, int $deref ]]]]] )*/ $info = ldap_get_entries($ds, $sr); //Print Return Schema print_r( $info['count']); for ($i=0; $i < $info["count"]; $i++){ //Print Every One echo $info[$i]["dn"]."\n"; } } else { echo "cannot connect to LDAP server at $AD_server."; } ?>