Re: add user to ldap using php
| From: | Patrick Brown | Date: | Tue, 20 Feb 2001 21:46:55 +0000 |
| Subject: | Re: add user to ldap using php | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40818@lists.php.net to get a copy of this message | ||
This is code from a working script to add a user account to a Novell NDS
database via Novell's LDAPv3.
Hope this helps.
//connect to LDAP
$ds=ldap_connect("172.17.20.10"); // must be a valid LDAP server!
if (!$ds) {
echo "Connection to LDAP server failed<br><br>";
exit();
}
//bind to LDAP
$r=ldap_bind($ds,"cn=ftpadmin, ou=Corp, o=PMX", "engineer");
if (!$r) {
echo "LDAP bind failed<br><br>";
exit();
}
//prepare the data to be added
$info1["cn"]=$login;
$info1["sn"]=$login;
$info1["objectclass"]="inetOrgPerson";
// add data to directory
$r=ldap_add($ds, "cn=$login, ou=SomeOU, o=Org", $info1);
//Close the LDAP connection.
ldap_close($ds);
""Richard Lynch"" <richard@zend.com> wrote in message
news:02c401c09a4c$98a7ce20$64aa8ed8@142.170.100...
> > $a=ldap_add($ds, "uid=beau, dc=graduate, dc=com", $info);
> > but it's an error
> > Waring LDAP: add operation could not be complete in. <my php file>
>
> I don't know much about LDAP:
>
> Have you checked that $ds is a valid LDAP connection?
> Can you get your own record out of LDAP using it?
> Presumably LDAP has some notion of who can add records (or whatever they
> called them) and who can't.
> Are you sure the user connected in ldap_open() is empowered to add records
> at that level in the LDAP space?
>
> --
> Visit the Zend Store at http://www.zend.com/store/
> Wanna help me out? Like Music? Buy a CD:
> http://l-i-e.com/artists.htm
> Volunteer a little time: http://chatmusic.com/volunteer.htm
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>