I want to Read, Add and Delete users from a Windows using .NET code. How can I do that?
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Inheritance impossible in Windows Runtime Componen
Here's some sample code for creating a windows user:
Adding a reference to System.DirectoryServices will let you read all windows users doing something like this:
The DirectoryServices Namespace in general should let you navigate and read the Active Directory
You will want to use the ActiveDirectory and DirectoryEntry
LDAP
is one option I would thinkWinNT
would works as well.You can access the directory with WinNT:// like this
Here are a few helpful links that have examples for adding/removing etc
Working with Users
SO Remove User
Also I had a few questions involving ActiveDirectory use a month or so ago (so I don't remember them in depth). Maybe some stuff from my profile can help you out. Good Luck
Apart from the other answers which are definitely valid and good we have also used LINQ to AD...
http://linqtoad.codeplex.com/
...on some projects which can make simple querying quite easy.