2015-09-05 11 views
0

是否有可能使inetOrgPerson成爲posixgroup的成員,而不是在cn中添加手動條目,即時通訊使用php和ldap,但是我似乎碰到過這樣的:是否有可能使inetOrgPerson在ldap PHP中使用活動目錄中的posixGroup的成員

Modify: Object class violation 

代碼:

$ldap = ldap_connect("localhost") or die("Unable to connect to server."); 
ldap_set_option($ldap,LDAP_OPT_PROTOCOL_VERSION,3); 
$dn = "cn=admin,dc=*******,dc=com"; 

ldap_bind($ldap,$dn,"*****") or die("Unable to connect to server.."); 
$dn = "cn=********,cn=*********,cn=*********,ou=A*******,dc=********,dc=com"; 

     $entry["cn"] = "MerPaul"; 
     $entry["objectClass"] = "inetOrgPerson"; 

     ldap_mod_add($ldap,$dn,$entry); 

我到底做錯了什麼?

回答

2

LDAP中的objectClass具有可選和必填字段。 inetOrgPerson也不例外。

inetOrgPerson必填字段爲sncn

$entry["cn"] = "MerPaul"; 
    $entry["sn"] = "Joe" 
    $entry["objectClass"] = "inetOrgPerson"; 

    ldap_mod_add($ldap,$dn,$entry); 
+0

感謝您的回答,我剛剛更改了代碼以反映此問題,並得到相同的錯誤。 – JoelS

+0

您應該通過使用命令行LDAP客戶端來獲得更多信息。例如,如果沒有sn屬性,我會得到ldap_add:對象類違規(65)其他信息:對象類'inetOrgPerson'需要屬性'sn'。但是它對我來說很有用。 –

+0

這個命令行工具是:ldapadd -D cn = admin,dc = *******,dc = com -W –

相關問題