开发者

Password Last Set Time incorrect - Active Directory

I have a method that allows me to set a users active directory password by passing in their username as a variable. after setting the password, i am checking to see if more than 5 minutes have passed before allowing another pa开发者_运维技巧ssword reset. i have a break point set, and when i look at the password last set time (after running the Modify User method 1 time), the time is set 4 hours in the future. Any ideas?

thanks,

Jason

if(DateTime.Now.Subtract(PasswordLastSet).TotalMinutes > 5)


public void ModifyUser(string username)
    {
        string sPwd = SetSecurePassword();

        DirectoryEntry entry = GetDirectoryEntry();
        DirectorySearcher search = new DirectorySearcher(entry);
        search.Filter = "(SAMAccountName=" + username + ")";

        SearchResult sResult = search.FindOne();
        if (sResult != null)
        {
            try
            {
                DirectoryEntry updateEntry = sResult.GetDirectoryEntry();
                updateEntry.Invoke("SetPassword", new object[] { sPwd });
                updateEntry.CommitChanges();
                updateEntry.Close();
                passWord = sPwd.ToString();

            }


            catch (Exception ex)
            {
                lblErrorMessage.Text = ex.ToString();
            }
        }


Get the local time instead when viewing the Password Last Set Time


Most likely this is because of your timezone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜