2011-04-27 6 views
0

사용자 이름을 변수로 전달하여 사용자가 활성 디렉토리 비밀번호를 설정할 수있는 방법이 있습니다. 암호를 설정 한 후 다른 암호 재설정을 허용하기 전에 5 분 이상 지났는지 확인합니다. 나는 브레이크 포인트를 설정하고 암호를 마지막으로 설정 한 시간 (Modify User 방법을 1 번 실행 한 후)을 볼 때 시간은 4 시간 후에 설정됩니다. 어떤 아이디어?비밀번호 마지막 설정 시간이 잘못됨 - Active Directory

덕분에,

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(); 
      } 
     } 

답변

0

암호를 볼 때 로컬 시간 가져 오기 마지막 설정 시간

0

제이슨은 대부분의 경우이 때문에 시간대이다.