01-04-2006, 23:27
|
|
מנהל פורום מערכות הפעלה - הרובע המייקרוסופטי.
|
|
חבר מתאריך: 07.10.04
הודעות: 13,777
|
|
אני מבין לליבך
חיפוש זריז באתר של מיקרוסופט:
קוד:
//COM Interop for accessing the IADsLargeInteger interface
using ActiveDs;
using System.DirectoryServices;
public static void GetLockoutTime(DirectoryEntry de)
{
// Change this to a valid ADSPath in your implementation of
// Active Directory.
de.Path = "LDAP://CN=user1,OU=TechWriters,DC=Fabrikam,DC=Com";
if (de.Properties.Contains("lockoutTime"))
{
IADsLargeInteger int64Value =
(IADsLargeInteger)de.Properties["lockoutTime"].Value;
// This is the standard formula for converting the large integer
// (it's highpart and lowpart) into a readable value.
long largeInt =
(long)((uint) int64Value.LowPart +
(((long) int64Value.HighPart) << 32 ));
if (largeInt != 0)
{
Console.WriteLine("Lockout Status {0}", largeInt);
//pad the date with the starting date of 1\1\1601
DateTime dtmPad = new DateTime(1601, 1, 1);
DateTime dtm = new DateTime(largeInt);
Console.WriteLine("DC reported time account locked is {0}",
dtm.AddTicks(dtmPad.Ticks).ToLocalTime().ToString( ));
}
else Console.WriteLine("lockoutTime is set to: {0}", largeInt);
}
else Console.WriteLine("lockoutTime is not set");
}
כפי שכבר ציינתי קודם, אני מעדיף פתרון כזה מכיוון שהוא חוסך לך מעבר על כמה שרתי DC, במידה ויש לך.
שים לב, אם הפרמטר lockouttime אינו מוגדר או 0, אז המשתמש אינו נעול.
לקוח מכאן
_____________________________________
נערך לאחרונה ע"י קוביבי בתאריך 01-04-2006 בשעה 23:27.
סיבה: שגיאת כתיב..
|