将用户添加到AD的问题 [英] Problem with adding User to AD
问题描述
我在将用户添加到AD时遇到问题。
每次我收到拒绝访问:(
有人能帮帮我吗?
这是我的代码:
试试
{
const string Domain =name.domain.pl;
const string Container =OU = Users,OU = IT, DC = name,DC = domain,DC = pl;
const string Username =xkorytkad;
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain,Domain,Container );
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext,Username);
UserPrincipal UserAD = new UserPrincipal(principalContext,adAdminLogin,adAdminPassword,true);
UserAD.UserPrincipalName =testuser;
UserAD.Name =testuser;
UserAD.GivenName =testuser;
UserAD.Surname =testuser;
UserAD.DisplayName =testuser;
UserAD.Desc ription =testuser;
UserAD.Enabled = false;
UserAD.Save();
MessageBox.Show(用户添加成功:));
}
catch(例外情况)
{
MessageBox.Show(例如ToString());
}
请帮助:(
Hi,
I have a problem with adding user to AD.
Everytime I got "Access denied" :(
Could someone help me ??
Here is my code:
try
{
const string Domain = "name.domain.pl";
const string Container = "OU=Users,OU=IT,DC=name,DC=domain,DC=pl";
const string Username = "xkorytkad";
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, Domain, Container);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, Username);
UserPrincipal UserAD = new UserPrincipal(principalContext, "adAdminLogin", "adAdminPassword", true);
UserAD.UserPrincipalName = "testuser";
UserAD.Name = "testuser";
UserAD.GivenName = "testuser";
UserAD.Surname = "testuser";
UserAD.DisplayName = "testuser";
UserAD.Description = "testuser";
UserAD.Enabled = false;
UserAD.Save();
MessageBox.Show("User added successfully :)");
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
Please help :(
推荐答案
好的,那么如何解决这个问题?
OK, then how to solve this problem ?
这篇关于将用户添加到AD的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!