我想通过将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;
}
答案 0 :(得分:5)
您需要做的就是:
user.Propertise["lockoutTime"].Value = 0;
user.CommitChanges()