PHP LDAP and Acitve Directory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Anakinz
Forum Newbie
Posts: 2
Joined: Mon Sep 09, 2002 4:18 am

PHP LDAP and Acitve Directory

Post by Anakinz »

Hi !!!

first, i want to apologize for my english !!! LOL

Oki, i try to create a php interface to manage a Win2k Active Directory server.

I would like to create a user account but I have some troubles.

I know I can do it with PHP LDAP functions, but when I try, the created account is Disable !!!

Moreover, i would like to know how to set the user password !!!

I need help !!!

Here a part of my code :

$ds=ldap_connect("myserver");


if ($ds) {

$dn ="cn=administrateur,cn=Users, DC=mydomain,dc=local";
$pwd ="adm_pwd";
$r=ldap_bind($ds,$dn,$pwd);

$info["cn"]="Bob";
$info["objectclass"]="user" ;
$info["samaccountname"]="bob";
$info["sn"]="bob";
$info["mail"]="bob3@somewhere.fr";
$info["userpassword"]="azerty";
$info["userprincipalname"]="bob3@mydomain.local";

$r=ldap_add($ds, "cn=bob, cn=users,dc=mydomain, dc=local", $info);

ldap_close($ds);

} else {
echo "Impossible de se connecter au serveur LDAP ";
}
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Post by 9902468 »

I dont know that much about MS AD, but it sounds like new accounts are disabled by default when created... Query that new account you just created and see all the attributes it has, might be useful, heritance is sometimes tricky. Also compare a user object that you have created and one that has been created with ms supplied tool (Query both from php). Any differences?

You can do like:

Code: Select all

$user_data_result = ldap_search($ldapConnection, "user_context", "user_dn");
$user_data_array = ldap_get_entries($ldapConnection, $user_data_result);

echo "<pre>";
print_r($user_data_array);
echo "</pre>";
And you see all the data that the query returned...
Hope that helps

-9902468
User avatar
sjunghare
Forum Newbie
Posts: 16
Joined: Tue Sep 03, 2002 6:22 am
Location: Pune

Post by sjunghare »

Check the Active DirectoryServer Configuration

http://www.dit.gov.bt/~takeshi/material ... index.html

Sachin Junghare
________________________
Anakinz
Forum Newbie
Posts: 2
Joined: Mon Sep 09, 2002 4:18 am

Post by Anakinz »

Sorry sjunghare


but I have an access denied when I try to see this page !!!
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Followup ..

Post by NoReason »

Just wondering if anyone knows of a good resource on active directory attribute names and what not, to use within the php ldap queries.

IE: can you set passwrod using ldap, or is it 100% kerberose.
how can set there disabled flag on or off?
(note: disabling using ADSI is freakin simple)


What are the various attributes names for a user object?
Post Reply