Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Active Directory > Acitve Directory lockoutDuration

Reply
Thread Tools Display Modes

Acitve Directory lockoutDuration

 
 
Ollie
Guest
Posts: n/a

 
      08-24-2004
I have defined the 'Account Lockout Policy' values to be 30 minutes
(duration & reset) in the Default Domain Security Settings in control panel
(Domain Security Policy) of a windows 2003 machine.

I am attempt to reading the 'lockoutDuration' programmatically using C#
(.Net), the code is shown below:

string nameContext = "XXXXXXXXXXX";
System.DirectoryServices.DirectorySearcher dirSearcher = new
System.DirectoryServices.DirectorySearcher(nameCon text);
dirSearcher.PropertiesToLoad.Add("lockoutDuration" );

System.DirectoryServices.DirectoryEntry dirEntry = dirSearcher.SearchRoot;

IADsLargeInteger int64Val =
(IADsLargeInteger)dirEntry.Properties["lockoutDuration"].Value;
System.Int64 largeInt = int64Val .HighPart * 0x100000000 + int64Val.LowPart;

System.TimeSpan ts = new TimeSpan(largeInt);
result = ts.Minutes;

The problem is the value returned is -37 minutes !!!!

So I guess I have made a mistake somewhere, can anyone spot it?

Cheers in advance

Ollie


 
Reply With Quote
 
 
 
 
Joe Richards [MVP]
Guest
Posts: n/a

 
      08-24-2004
The negative value is correct, it is delta from the current time.

The 7 means there is some sort of error in the math somewhere. I don't do NET so
not sure where that could be, hopefully joek will be along shortly with the
answer there. If you just want to work with it it should be that you should be
getting

-18000000000

for the lockoutDuration value.

Divide that by 600000000 and you have your delta in minutes, -30.

joe



--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net



Ollie wrote:
> I have defined the 'Account Lockout Policy' values to be 30 minutes
> (duration & reset) in the Default Domain Security Settings in control panel
> (Domain Security Policy) of a windows 2003 machine.
>
> I am attempt to reading the 'lockoutDuration' programmatically using C#
> (.Net), the code is shown below:
>
> string nameContext = "XXXXXXXXXXX";
> System.DirectoryServices.DirectorySearcher dirSearcher = new
> System.DirectoryServices.DirectorySearcher(nameCon text);
> dirSearcher.PropertiesToLoad.Add("lockoutDuration" );
>
> System.DirectoryServices.DirectoryEntry dirEntry = dirSearcher.SearchRoot;
>
> IADsLargeInteger int64Val =
> (IADsLargeInteger)dirEntry.Properties["lockoutDuration"].Value;
> System.Int64 largeInt = int64Val .HighPart * 0x100000000 + int64Val.LowPart;
>
> System.TimeSpan ts = new TimeSpan(largeInt);
> result = ts.Minutes;
>
> The problem is the value returned is -37 minutes !!!!
>
> So I guess I have made a mistake somewhere, can anyone spot it?
>
> Cheers in advance
>
> Ollie
>
>

 
Reply With Quote
 
Joe Kaplan \(MVP - ADSI\)
Guest
Posts: n/a

 
      08-24-2004
I think that example might be wrong. The problem is that even though
LowPart is typed as an Int32, it really needs to be a UInt32 since if if the
high bit is set, it will be treated as a negative number and the addition
will not give the expected result.

The easiest way to do this is to just use the DirectorySearcher directly
doing a base level search on the domain root. The DirectorySearcher
properly converts the value to an Int64 for you.

Joe K.

"Ollie" <> wrote in message
news:...
> I have defined the 'Account Lockout Policy' values to be 30 minutes
> (duration & reset) in the Default Domain Security Settings in control

panel
> (Domain Security Policy) of a windows 2003 machine.
>
> I am attempt to reading the 'lockoutDuration' programmatically using C#
> (.Net), the code is shown below:
>
> string nameContext = "XXXXXXXXXXX";
> System.DirectoryServices.DirectorySearcher dirSearcher = new
> System.DirectoryServices.DirectorySearcher(nameCon text);
> dirSearcher.PropertiesToLoad.Add("lockoutDuration" );
>
> System.DirectoryServices.DirectoryEntry dirEntry = dirSearcher.SearchRoot;
>
> IADsLargeInteger int64Val =
> (IADsLargeInteger)dirEntry.Properties["lockoutDuration"].Value;
> System.Int64 largeInt = int64Val .HighPart * 0x100000000 +

int64Val.LowPart;
>
> System.TimeSpan ts = new TimeSpan(largeInt);
> result = ts.Minutes;
>
> The problem is the value returned is -37 minutes !!!!
>
> So I guess I have made a mistake somewhere, can anyone spot it?
>
> Cheers in advance
>
> Ollie
>
>



 
Reply With Quote
 
Ollie
Guest
Posts: n/a

 
      08-24-2004
cheers for the info Joe

Ollie

"Joe Kaplan (MVP - ADSI)" <> wrote
in message news:%...
> I think that example might be wrong. The problem is that even though
> LowPart is typed as an Int32, it really needs to be a UInt32 since if if

the
> high bit is set, it will be treated as a negative number and the addition
> will not give the expected result.
>
> The easiest way to do this is to just use the DirectorySearcher directly
> doing a base level search on the domain root. The DirectorySearcher
> properly converts the value to an Int64 for you.
>
> Joe K.
>
> "Ollie" <> wrote in message
> news:...
> > I have defined the 'Account Lockout Policy' values to be 30 minutes
> > (duration & reset) in the Default Domain Security Settings in control

> panel
> > (Domain Security Policy) of a windows 2003 machine.
> >
> > I am attempt to reading the 'lockoutDuration' programmatically using C#
> > (.Net), the code is shown below:
> >
> > string nameContext = "XXXXXXXXXXX";
> > System.DirectoryServices.DirectorySearcher dirSearcher = new
> > System.DirectoryServices.DirectorySearcher(nameCon text);
> > dirSearcher.PropertiesToLoad.Add("lockoutDuration" );
> >
> > System.DirectoryServices.DirectoryEntry dirEntry =

dirSearcher.SearchRoot;
> >
> > IADsLargeInteger int64Val =
> > (IADsLargeInteger)dirEntry.Properties["lockoutDuration"].Value;
> > System.Int64 largeInt = int64Val .HighPart * 0x100000000 +

> int64Val.LowPart;
> >
> > System.TimeSpan ts = new TimeSpan(largeInt);
> > result = ts.Minutes;
> >
> > The problem is the value returned is -37 minutes !!!!
> >
> > So I guess I have made a mistake somewhere, can anyone spot it?
> >
> > Cheers in advance
> >
> > Ollie
> >
> >

>
>



 
Reply With Quote
 
Ollie
Guest
Posts: n/a

 
      08-24-2004
cheers for the info Joe

Ollie

"Joe Richards [MVP]" <> wrote in message
news:...
> The negative value is correct, it is delta from the current time.
>
> The 7 means there is some sort of error in the math somewhere. I don't do

NET so
> not sure where that could be, hopefully joek will be along shortly with

the
> answer there. If you just want to work with it it should be that you

should be
> getting
>
> -18000000000
>
> for the lockoutDuration value.
>
> Divide that by 600000000 and you have your delta in minutes, -30.
>
> joe
>
>
>
> --
> Joe Richards Microsoft MVP Windows Server Directory Services
> www.joeware.net
>
>
>
> Ollie wrote:
> > I have defined the 'Account Lockout Policy' values to be 30 minutes
> > (duration & reset) in the Default Domain Security Settings in control

panel
> > (Domain Security Policy) of a windows 2003 machine.
> >
> > I am attempt to reading the 'lockoutDuration' programmatically using C#
> > (.Net), the code is shown below:
> >
> > string nameContext = "XXXXXXXXXXX";
> > System.DirectoryServices.DirectorySearcher dirSearcher = new
> > System.DirectoryServices.DirectorySearcher(nameCon text);
> > dirSearcher.PropertiesToLoad.Add("lockoutDuration" );
> >
> > System.DirectoryServices.DirectoryEntry dirEntry =

dirSearcher.SearchRoot;
> >
> > IADsLargeInteger int64Val =
> > (IADsLargeInteger)dirEntry.Properties["lockoutDuration"].Value;
> > System.Int64 largeInt = int64Val .HighPart * 0x100000000 +

int64Val.LowPart;
> >
> > System.TimeSpan ts = new TimeSpan(largeInt);
> > result = ts.Minutes;
> >
> > The problem is the value returned is -37 minutes !!!!
> >
> > So I guess I have made a mistake somewhere, can anyone spot it?
> >
> > Cheers in advance
> >
> > Ollie
> >
> >



 
Reply With Quote
 
Junior Member
Join Date: Feb 2012
Posts: 1

 
      02-07-2012
Hi,

How we can set the value for lockoutDuration using c#?

Thanks in Advance,

Kailas.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
auditing active directory not working properly directory serviceaccess ThijsD Windows Server 4 1 Week Ago 02:41 AM
Making Another Active Directory a Peer in Directory Tree CHANGE USERNAME TO westes Active Directory 1 07-06-2004 09:00 PM
Active Directory restore - recovery OK but fails on Directory Services start up Patrick Active Directory 2 06-16-2004 05:49 PM
Acitve Directory(AD) or AD in Application Mode(ADAM) Sasi Active Directory 1 04-08-2004 06:42 PM
Netscape Directory Server meets Active Directory? Aravind Active Directory 2 02-18-2004 09:34 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59