您好,我是本地 Active Directory 的新手,我的问题是使用 API 创建用户。我对此进行了搜索,但没有找到任何文档。我发现的一件事是 AD Connect,但通过文档没有得到任何线索。任何人都可以让我知道这是可能的还是我做错了什么?
最佳答案
是的,你可以! rickvdbosch 提供的链接将使您走得更远。
首先,您需要添加一个
using System.DirectoryServices.AccountManagement;
对您的文件的声明,并且可能是对System.DirectoryServices.AccountManagement
程序集的引用。您可以使用如下方式连接到 AD:
var username = "你的用户名"; var password = "你的密码"; var domain = "你的域名"; var ctx = new PrincipalContext(ContextType.Domain, domain, username, password);
然后使用 PrincipalContext 对象执行操作。 (rickvdbosch 提供的链接中有一个很好的例子。)
关于active-directory - Active Directory 内部使用 API 创建/删除用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53853766/