在 Active Directory mmc 管理单元中,您看不到“未设置”的属性。当您使用 ADSIEDIT.MSC 工具时,如果属性值为空,您确实会将它们视为“未设置”。
如何在 .Net 代码中将属性设置为“未设置”?
这是 Powershell 中的答案,但我需要使用一些 .Net 代码(VB.Net/C#)来完成。http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/d6d0bfa1-73da-41ea-a7f5-f622de9f7d1b/ http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/d6d0bfa1-73da-41ea-a7f5-f622de9f7d1b/
ps msExchHideAddressLists 是罪魁祸首属性,当其在此域中为 True 或 False 时,它会阻止用户信息从 AD 复制到 Sharepoint。
In the MSDN http://support.microsoft.com/kb/260251/en-us你可以找到:
在支持 LDAP 的常用目录中,不存在没有值的属性。当通过更改、替换或追加操作将属性值设置为非空值时,如果该属性尚不存在,则会创建该属性。同样,如果一个属性被修改为没有值(或多个值),则整个属性将被删除。有时您可能希望将属性设置为 null。虽然支持 LDAP 的目录中不存在此概念,但您可以通过完全删除该属性并指定要清除该属性来实现此目的。
这是一个使用的示例System.DirectoryServices
:
/* Connection to Active Directory
*/
DirectoryEntry deBase = new DirectoryEntry("LDAP://192.168.183.220:389/dc=societe,dc=local", "administrateur", "adm");
/* Directory Search
*/
DirectorySearcher dsLookForOUs = new DirectorySearcher(deBase);
dsLookForOUs.Filter = "(objectCategory=organizationalUnit)";
dsLookForOUs.SearchScope = SearchScope.Subtree;
dsLookForOUs.PropertiesToLoad.Add("cn");
dsLookForOUs.PropertiesToLoad.Add("ou");
dsLookForOUs.PropertiesToLoad.Add("telephoneNumber");
SearchResultCollection srcOUs = dsLookForOUs.FindAll();
foreach (SearchResult srOU in srcOUs)
{
Console.WriteLine("{0}", srOU.Path);
DirectoryEntry de = srOU.GetDirectoryEntry();
if (de.Properties["TelephoneNumber"].Value!= null)
{
// Both solutions are working. Don't forget to commit
//de.Properties["TelephoneNumber"].Clear();
de.Properties["TelephoneNumber"].Value=null;
de.CommitChanges();
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)