public static void RemoveMember(string userDn, string groupDn) { try { DirectoryEntry dirEntry = AD.GetObjectDirectoryEntry(groupDn); dirEntry.Properties["member"].Remove(userDn); dirEntry.CommitChanges(); dirEntry.Close(); dirEntry.Dispose(); } catch (DirectoryServicesCOMException E) { throw E; } }
public static void Unlock(string userDn) { try { DirectoryEntry user = AD.GetObjectDirectoryEntry(userDn); user.Properties["LockOutTime"].Value = 0; user.CommitChanges(); user.Close(); user.Dispose(); } catch (DirectoryServicesCOMException E) { throw E; } }
public static void Disable(string userDn) { try { DirectoryEntry user = AD.GetObjectDirectoryEntry(userDn); int val = (int)user.Properties["userAccountControl"].Value; user.Properties["userAccountControl"].Value = val | 0x2; user.CommitChanges(); user.Close(); user.Dispose(); } catch (DirectoryServicesCOMException E) { throw E; } }
public static void UpdatePasword(string userDn, string password) { try { DirectoryEntry user = AD.GetObjectDirectoryEntry(userDn); user.Invoke("SetPassword", new object[] { password }); user.CommitChanges(); user.CommitChanges(); user.Close(); user.Dispose(); } catch (DirectoryServicesCOMException E) { throw E; } }
private static string GetDistinguishedName(string userName) { return(AD.GetObjectDistinguishedName(userName, ObjectClass.user, ReturnType.distinguishedName)); }