try { string strDC = GetDomainController(strOldDAGroupDN.Substring(strOldDAGroupDN.IndexOf("DC")).Replace("DC=", "").Replace(",", ".").Replace("}", "")); DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + strDC + "/" + strOldDAGroupDN); dirEntry.Username = strEntAdminUser; dirEntry.Password = strEntAdminPW; dirEntry.Properties["member"].Remove(strHostDN); dirEntry.CommitChanges(); dirEntry.Close(); } catch (Exception e) { TextWriter errorWriter = Console.Error; errorWriter.WriteLine("Error while removing computer account to AD group!"); errorWriter.WriteLine(e.Message); }
CommitChanges
PropertyValueCollection.Add/Remove
null
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)