LDAP例外对象类违反:Add new User

本文关键字:Add new User 对象 LDAP | 更新日期: 2023-09-27 17:49:28

我试图在LDAP目录中创建一个用户,但我得到以下错误:"对象类违规"。有人能提出解决办法吗?

try             
{
    DirectoryEntry ouEntry = new DirectoryEntry("LDAP://localhost:389/ou=people,dc=wso2,dc=com","cn=admin,dc=wso2,dc=com", "toto", AuthenticationTypes.Secure);
    DirectoryEntry childEntry = ouEntry.Children.Add("CN=tati toto", "inetOrgPerson");
    childEntry.Properties["sn"].Add("toto");
    childEntry.CommitChanges();
}
catch(Exception Ex)             
{
    Console.WriteLine("Exception : "+ Ex.Message);
}

LDAP例外对象类违反:Add new User

我解决它,

 try             
 {
DirectoryEntry ouEntry = new DirectoryEntry("LDAP://localhost:389/ou=people,dc=wso2,dc=com","cn=admin,dc=wso2,dc=com", "toto", AuthenticationTypes.Secure);
DirectoryEntry childEntry = ouEntry.Children.Add("CN=tati toto", "top");
childEntry.Properties["objectclass"].Add("person");
childEntry.Properties["sn"].Add("toto");
childEntry.CommitChanges();
 }
 catch(Exception Ex)             
{
Console.WriteLine("Exception : "+ Ex.Message);
}