如何使用lockoutTime解锁AD中的用户帐户

时间:2011-08-10 13:37:58

标签: active-directory

我想通过将lockoutTime属性设置为零来解锁AD中的用户帐户。问题是属性的值是System_ComObject。如何将属性的值设置为零?我使用以下代码来获取lockOut

的值

DirectoryEntry user = DirectoryEntry(DistinguishedName);

// user.Properties [“lockoutTime”]。值是System_Com对象

long fileTicks = LongFromLargeInteger(user.Properties [“lockoutTime”]。Value);

private long LongFromLargeInteger(object largeInteger)

{

System.Type type = largeInteger.GetType();

type = largeInteger.GetType();

int highPart =(int)type.InvokeMember(“HighPart”,BindingFlags.GetProperty,null,largeInteger,null);

int lowPart =(int)type.InvokeMember(“LowPart”,BindingFlags.GetProperty,null,largeInteger,null

);

return(long)highPart<< 32 | (UINT)lowPart;

}

1 个答案:

答案 0 :(得分:5)

您需要做的就是:

user.Propertise["lockoutTime"].Value = 0;
user.CommitChanges()