2017-05-11 3 views
1

Active DirectoryとPHPの統合については本当に苦労しています。私が更新しようとしているフィールドは、givenname、sn、mail、telephonenumber、company、department、titleです。私は、私が代わりにLDAPのLDAPSを使用する必要があることを発見したインターネットを検索することから警告:ldap_modify():変更:サーバの実行が望ましくない

Warning: ldap_modify(): Modify: Server is unwilling to perform in E:\IIS^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

が、私はここで間違って何であるかわからない:それは私に次のエラーを与えている

function get_active_directory_info($username, $password) 
{ 
    $conn   = ldap_connect("DC-1"); 
    if($conn==FALSE) 
    { 
     return array(FALSE, FALSE); 
    } 
    else 
    { 
     $bind = ldap_bind($conn, $username, $password); 
     ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION,3); 
     ldap_set_option($conn, LDAP_OPT_REFERRALS,0); 
     $unit   = "OU=Staff,OU=Users,DC=example,DC=internal"; 
     $filter   = "(&(objectCategory=person)(sAMAccountName=*)(!(UserAccountControl=514)))"; 
     $results  = array(); 
     $justthese  = array("sn", "givenname", "mail", "company","department","title","telephonenumber","samaccountname", "cn"); 
     $sr=ldap_search($conn, $unit, $filter, $justthese); 
     $info = ldap_get_entries($conn, $sr);   
     for($i = 0; $i < $info["count"]; $i++) 
     { 
      $cn = $info[$i]["cn"][0]; 
      if(substr($cn, -3) != "ADM") 
      { 
       $results[$i]["id"] = $i + 1; 
       if(empty($info[$i]["givenname"][0])==FALSE) 
       { 
        $results[$i]["first"] = $info[$i]["givenname"][0]; 
       } 
       if(empty($info[$i]["sn"][0])==FALSE) 
       { 
        $results[$i]["last"] = $info[$i]["sn"][0]; 
       } 
       if(empty($info[$i]["mail"][0])==FALSE) 
       { 
        $results[$i]["email"] = $info[$i]["mail"][0]; 
       }  
       if(empty($info[$i]["company"][0])==FALSE) 
       { 
        $results[$i]["company"] = $info[$i]["company"][0]; 
       } 
       if(empty($info[$i]["title"][0])==FALSE) 
       { 
        $results[$i]["title"] = $info[$i]["title"][0]; 
       }  
       if(empty($info[$i]["department"][0])==FALSE) 
       { 
        $results[$i]["department"] = $info[$i]["department"][0]; 
       }  
       if(empty($info[$i]["telephonenumber"][0])==FALSE) 
       { 
        $results[$i]["number"] = $info[$i]["telephonenumber"][0]; 
       }  
       if(empty($info[$i]["samaccountname"][0])==FALSE) 
       { 
        $results[$i]["username"] = $info[$i]["samaccountname"][0]; 
       } 
      } 
     } 
    }  
    return $results;  
} 

答えて

0

場合I正しく覚えている、あなたはパスワードを変更するためのLDAPが必要です、私はあなたがそれをやっていない参照してください。もっと単純な例でこれを試してみましたか、それがうまくいくか試してみてください。

私が提供した情報で以下のコードを変更しましたが、ホスト、ユーザー名、およびパスワードを変更する必要があります。これを試してみるとどうなりますか?

$r=ldap_bind($ds, "username", "password"); 

$ldapconn = ldap_connect("LDAP://HOST:389"); 

if ($ldapconn) { 

    // binding to ldap server 
    $ldapbind = ldap_bind($ldapconn, "username", "password"); 

    $justthese = array("otherTelephone"); 

    $search = ldap_search($ldapconn,"OU=Staff,OU=Users,DC=example,DC=internal", "(&(objectCategory=person)(sAMAccountName=*)(!(UserAccountControl=514)))", $justthese); 

    $entry = ldap_get_entries($ldapconn, $search); 

    $dn=$entry[0]["dn"]; 

    $userdata=array(); 
    $userdata["otherTelephone"][0]= "NEWPHONENUMBER";  
    ldap_modify($ldapconn, $dn, $userdata); 
} 

何が起こるか教えてください。

関連する問題