我最初使用的是ActiveDirectoryServices
,但根據其他成員的建議在此處切換到ActiveDirectoryServices.AccountManagment
。與合作更容易,但它提出了一個挑戰。當返回LastPasswordSet
時,它是UTC而不是當地時間。我怎樣才能解決這個問題?ActiveDirectoryServices.AccountManagment - LastPasswordSet - UTC時間
感謝,
傑森
public UserPrincipal GetUser(string sUserName)
{
PrincipalContext oPrincipalContext = GetPrincipalContext();
UserPrincipal oUserPrincipal =
UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);
if (oUserPrincipal != null)
{
BuildUser(oUserPrincipal);
}
return oUserPrincipal;
}
private void BuildUser(UserPrincipal user)
{
//Populate the user with items available in the UserPrincipal object
if (user != null)
{
if (user.LastPasswordSet.HasValue)
this.PasswordLastSet = (DateTime)user.LastPasswordSet;
}
}