我最初使用的是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;
}
}