假设您已使用simiple语法连接到Active Directory:
string adPath = "LDAP://server.domain.com/CN=John,CN=Users,dc=domain,dc=com";
DirectoryEntry userEntry = Settings.GetADEntry(adPath);
现在您要查看该用户的属性,例如邮件属性:
Console.WriteLine("User's mail attribute is " + userEntry.Properties["mail"]);
现在我该如何删除邮件属性值?
答案 0 :(得分:17)
事实证明这很简单,虽然不是很常用......
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();
答案 1 :(得分:0)
不确定是否可以删除它,因为用户对象通常遵循公司架构,但可能会有以下内容:
userEntry.Properties["mail"] = null;
或者也许:
userEntry.Invoke("Put", "mail", null);
然后:
userEntry.CommitChanges();