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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jiing

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

    <?php
    $ldapServer="ld ap://192.168.1.211";
    $ldapPort="389" ;
    $ldapconn=ldap_ connect($ldapSe rver,$ldapPort) ;
    $ldaprdn="uid=r oot, ou=People, dc=aitc, dc=com, dc=tw";
    $ldappass="abcd ";

    if($ldapconn){
    echo "connect to ".$ldapServ er." 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($ldap conn, $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["objectclas s"][0]="account";
    $data["objectclas s"][1]="posixAccount" ;
    $data["objectclas s"][2]="top";
    $data["userpasswo rd"]="tester";
    $data["loginshell "]="/usr/local/bin/bash";
    $data["uidnumber"]=3100;
    $data["gidnumber"]=3100;
    $data["homedirect ory"]="/home/tester";
    $data["gecos"]="Tester 1";

    // Before ldap_add(), should check the user already exists or not
    if(!ldap_add($l dapconn,"uid=te ster, 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($lda pconn);
    ?>

    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和gidnu mber), 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-
Working...