Problem with LDAP-add

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

    Problem with LDAP-add

    Hello
    I am using php5 and trying to add users to the AD with the following
    php-script, but it doesnt work. Login,... works fine but I get an
    error:
    "ldap_add() [function.ldap-add]: Add: Referral in
    C:\wamp\www\val idAdminPage.php on line 51"(line 51 is the line which
    does the add). an the output "There was a problem" which is the output
    if the add goes wrong.

    Any ideas
    THanx
    CB

    The script:

    $ldaprdn = "admin@ville.do m";
    $ldappass ="<password> ";
    $ds = '10.121.2.202';
    $dn = "CN=jmiller,CN= Users;dc=ville, dc=dom";
    $ldapport = 389;
    $ldapconn = ldap_connect($d s, $ldapport)
    or die("Could not connect to LDAP server.");
    if ($ldapconn)
    {
    ldap_set_option ($ldapconn, LDAP_OPT_PROTOC OL_VERSION,3);
    ldap_set_option ($ldapconn, LDAP_OPT_REFERR ALS,0);
    $ldapbind = ldap_bind($ldap conn, $ldaprdn, $ldappass);
    if ($ldapbind){
    $adduserAD["cn"][0] = "jmiller";
    $adduserAD["samaccountname "][0] = "jmiller";
    $adduserAD["objectclas s"][0] = "top";
    $adduserAD["objectclas s"][1] = "person";
    $adduserAD["objectclas s"][2] = "organizational Person";
    $adduserAD["objectclas s"][3] = "user";
    $adduserAD["displaynam e"][0] = "jemp miller";
    $adduserAD["name"][0] = "jemp";
    $adduserAD["givenname"][0] = "miller";
    $adduserAD["sn"][0] = "Bisdorff";
    $adduserAD["company"][0] ="vdl";
    $adduserAD["descriptio n"][0] = "my description";
    $adduserAD["mail"][0] = "jmiller@ville. dom";
    $adduserAD["samaccountname "][0] = "jbisdorff" ;
    $adduserAD["userprincipaln ame"][0] ="jmiller@ville .dom";
    // add data to directory
    $result=ldap_ad d($ldapconn, $dn, $adduserAD);
    if ($result)
    echo "User added!";
    else
    echo "There was a problem!";

    ldap_unbind($ld apconn);

Working...