由于用户登录时候密码错误次数太多而被锁定.
现在需要用C#来实现对用户账号的解锁.
我尝试使用userAccountControl属性和Accountdisabled均不成功.
特来求救,感激不尽.

解决方案 »

  1.   

    PrincipalContext ctx = new PrincipalContext(ContextType.Domain, 
                                             "fabrikam.com", 
                                             "CN=Users,DC=fabrikam,DC=com", 
                                             "administrator", 
                                             "SecretPwd123");
            
    UserPrincipal usr = UserPrincipal.FindByIdentity(ctx, "John Smith");
    if (usr != null)
    {
        if (usr.IsAccountLockedOut())
            usr.UnlockAccount();    usr.Dispose();
    }
    ctx.Dispose(); http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.authenticableprincipal.unlockaccount.aspx