We have a c# script that needs to update/replace the proxyAddresses contents. I believe I understand how to add a range of values as follows:
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- feel free to correct any errors in the above code. If this looks correct - my understanding is that AddRange will append my new values rather than replacing the current values. Can someone please describe how I can remove/replace the existing contents of proxyAddresses with these new values..? Thanks in advance.
This will replace the
proxyAddresses
propertiesThere are more examples about how to work with proxyAddresses here