如何使用C#删除Windows用户帐户?
条款Thomsen很接近,您需要将DirectoryEntry.Remove方法传递给DirectoryEntry参数而不是字符串,例如:
DirectoryEntry localDirectory = new DirectoryEntry("WinNT://" + Environment.MachineName.ToString()); DirectoryEntries users = localDirectory.Children; DirectoryEntry user = users.Find("userName"); users.Remove(user);