0
我們有一個需要更新/替換proxyAddresses內容的c#腳本。 我相信我瞭解如何添加值的範圍如下:替換proxyAddresses值
DirectoryEntry entry = new DirectoryEntry(myConnectString);
DirectorySearcher Dsearch = new DirectorySearcher(entry);
Dsearch.Filter = "(sAMAccountName=" + theUser + ")";
SearchResult result = Dsearch.FindOne();
if (result != null)
{
if (result.Properties.Contains("proxyAddresses"))
{
DirectoryEntry Uentry = result.GetDirectoryEntry();
Uentry.Properties[proxyAddresses].AddRange(new object[] {"[email protected]", "[email protected]"});
Uentry.CommitChanges();
}
}
However-隨時糾正在上面的代碼中的任何錯誤。如果這看起來是正確的 - 我的理解是,AddRange將追加我的新值,而不是替換當前值。有人可以請描述我可以如何使用這些新值刪除/替換proxyAddresses的現有內容..?提前致謝。
這是否會更換代理地址的現有內容或只是追加到它? – dev
@dev它會*取代它* –
代碼是錯誤的,有人拒絕我的編輯。你需要引用屬性名稱。 – Mike