How do I clear out a user object attribute in Active Directory?

前端 未结 2 1296
悲哀的现实
悲哀的现实 2021-01-04 12:14

Suppose you have connected to Active Directory using the simple syntax:

string adPath = \"LDAP://server.domain.com/CN=John,CN=Users,dc=domain,dc=com\";
Direc         


        
相关标签:
2条回答
  • 2021-01-04 12:36

    Not sure that you can delete it since user objects usually follow a company schema but maybe something like the following will work:

    userEntry.Properties["mail"] = null;
    

    or maybe:

    userEntry.Invoke("Put", "mail", null); 
    

    then:

    userEntry.CommitChanges();
    
    0 讨论(0)
  • 2021-01-04 12:47

    It turns out to be pretty simple, albeit not very commonly used...

    string adPath = "LDAP://server.domain.com/CN=John,CN=Users,dc=domain,dc=com";
    DirectoryEntry userEntry = Settings.GetADEntry(adPath);
    userentry.Properties["mail"].Clear();
    userentry.CommitChanges();
    
    0 讨论(0)
提交回复
热议问题