![](/img/trans.png)
[英]DirectoryServicesCOMException when working with System.DirectoryServices.AccountManagement
[英]System.DirectoryServices.AccountManagement bootstrapping myself
我正在尝试在System.DirectoryServices.AccountManagement
命名空间上进行自我引导,以解决我遇到的另一个问题。 在网络中,我想在广告中切换“ ChangePasswordOnNextLogon”标志,并且此命名空间使其看起来很容易。
因此,我尝试使用与使用AdMembershipProvider
登录时所使用的用户名和密码相同的用户名和密码。
PrincipalContext oPrincipalContext =
new PrincipalContext(ContextType.Domain, "10.1.XXX.XXX", "DC=XXXXXXXX,DC=ORG",
ContextOptions.SimpleBind, AUserThatWorks, APasswordThatWorks);
UserPrincipal oUserPrincipal =
UserPrincipal.FindByIdentity(oPrincipalContext, AdUserName);
// we need to see if they can authenticate before changing password,so we have to turn this off manually. - EWB
oUserPrincipal.RefreshExpiredPassword();
bool b = oPrincipalContext.ValidateCredentials( AdUserName, AdPassword );
if (!b)
oUserPrincipal.ExpirePasswordNow();
return b;
但是,当它到达FindByIdentity
时,出现“用户名或密码错误”错误。
由于用户在其他地方工作,因此我认为它必须是获取主体上下文的其他参数之一。 有人给我提示吗? 我尝试将LDAP放在URL的前面,但是后来无法连接。 我很沮丧
谢谢,
Cal-
尝试简化PrincipalContext行:
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "XXXXXX.org", AUserThatWorks, PasswordThatWorks);
假设您的域是XXXXXXX.org。 您也可以尝试将域名放在用户名“ XXXXXX.org \\ username”的前面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.