C# 使用SetPassword以编程方式更改Active Directory密码,创建多个密码
我正在使用UserPrincipal类的SetPassword方法更改exchange密码。但问题是,它似乎要创建另一个密码并保留旧密码。我当前的密码是“123”,如果我这样做:C# 使用SetPassword以编程方式更改Active Directory密码,创建多个密码,c#,asp.net,exchange-server,C#,Asp.net,Exchange Server,我正在使用UserPrincipal类的SetPassword方法更改exchange密码。但问题是,它似乎要创建另一个密码并保留旧密码。我当前的密码是“123”,如果我这样做: PrincipalContext Adcontext = new PrincipalContext(ContextType.Domain, "domain", "superuser", "password"); UserPrincipal userdomain = UserPrincipal.FindByIdentit
PrincipalContext Adcontext = new PrincipalContext(ContextType.Domain, "domain", "superuser", "password");
UserPrincipal userdomain = UserPrincipal.FindByIdentity(Adcontext, "UserIWantToChange");
userdomain.SetPassword("newpassordcompletlynewinsaneinthebrain");
并且我尝试登录outlook,2密码将起作用!如果我使用“ValidateCredentials”,那么2也会起作用。这正常吗?我怎样才能防止这种情况 好吧,我找到了原因。我回答我的新问题是为了帮助更多有同样问题的人。这是由于缓存的域凭据造成的。你可以禁用它。这里有一个有用的链接,解释了如何做