ldap server can not replace the order of login, why?

J

jiing

<?php
$ldapServer="ldap://192.168.1.211";
$ldapPort="389";
$ldapconn=ldap_connect($ldapServer,$ldapPort);
$ldaprdn="uid=root, ou=People, dc=aitc, dc=com, dc=tw";
$ldappass="abcd";

if($ldapconn){
echo "connect to ".$ldapServer." successfully \n<br>";
}else{
echo "can't connect to LDAP server!\n<br>";
}
if ($ldapconn) {
// binding to ldap server to give update access
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
echo "LDAP binding successful...\n";
} else {
echo "LDAP binding failed...\n";
}
}
//data preparation
//I am not very sure what attribute should be filled
$data["uid"]="tester";
$data["cn"]="Tester 1";
$data["objectclass"][0]="account";
$data["objectclass"][1]="posixAccount";
$data["objectclass"][2]="top";
$data["userpassword"]="tester";
$data["loginshell"]="/usr/local/bin/bash";
$data["uidnumber"]=3100;
$data["gidnumber"]=3100;
$data["homedirectory"]="/home/tester";
$data["gecos"]="Tester 1";

// Before ldap_add(), should check the user already exists or not
if(!ldap_add($ldapconn,"uid=tester, ou=People, dc=aitc, dc=com,
dc=tw", $data)){
echo "There is a problem to create the account\n";
echo "Please contact your administrator!\n";
exit;
}else{
echo "account creation successfully";
}
ldap_close($ldapconn);
?>

I used ldapbrowser to connect LDAP server(openldap), and I can see all
the user,but I can not Add Entry,but I can Delete Entry
Then I wrote the php code above to add a new user tester(the
$data fields are all the fields of LDAP, but some fields were filled
by me randomly,like uidnumber和gidnumber), but if
I do not fill those fields, it will occurs the following warning
message

Warning: ldap_add(): Add: Object class violation in
d:\AppServ\www\LDAP_test1.ph
p on line 74
There is a problem to create the account
Please contact your administrator!

But I found the biggest problem is : my ldap server can not replace
the login order, i.e, I want to build accounts/passwords in openldap
server, then users can use the account/password in ldap server and
login freebsd server. But when I use the above php code to create a
tester account, the user "tester" still can not use tester/tester to
login freebsd host, why? Could you tell me.

Thanks in advanced.

-jiing-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top