471,582 Members | 1,363 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

Verify Network User Account isnt locked out.

On occasion a Network User Account gets locked out. This causes lots of
problems as the account is used to run different programs. The programs fail
when the user account is locked out.
I would like to write a c# program that will check if the Network User
Account is locked out?
Can someone point me in the right direction? An API?

TIA,
Vinny
Nov 17 '05 #1
2 5511

Hi there... you have this script here (VBScript)
http://www.rlmueller.net/Programs/IsUserLocked.txt

or you can just ask AD for example...

DirectoryEntry de = DirectoryEntry("WinNT://DomainName/UserAccount");
Console.WriteLine(de.Properties["IsAccountLocked"]);

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com

"Vinny Vinn" <Vi*******@discussions.microsoft.com> escribió en el mensaje
news:41**********************************@microsof t.com...
On occasion a Network User Account gets locked out. This causes lots of
problems as the account is used to run different programs. The programs
fail
when the user account is locked out.
I would like to write a c# program that will check if the Network User
Account is locked out?
Can someone point me in the right direction? An API?

TIA,
Vinny

Nov 17 '05 #2

"Vinny Vinn" <Vi*******@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
On occasion a Network User Account gets locked out. This causes lots of
problems as the account is used to run different programs. The programs
fail
when the user account is locked out.
I would like to write a c# program that will check if the Network User
Account is locked out?
Can someone point me in the right direction? An API?

TIA,
Vinny


You have at least two options:

1. You can use DirectoryServices and check the LOCKOUT bit in the
"userAccountControl" property of the AD user object.

const int ADS_UF_LOCKOUT = 0x00000010;
using(DirectoryEntry user = new
DirectoryEntry("LDAP://..../CN=userAcc0,DC=..,DC=..,DC=..", ...))
{
if (((int)user.Properties["userAccountControl"].Value &
ADS_UF_LOCKOUT) == 1)
{
Console.WriteLine("Account locked");
}
}
}

2. You can call LogonUser and check the return value and Win32 error code.

Willy.

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Reader | last post: by
8 posts views Thread by Lam | last post: by
reply views Thread by Ken Linder (KC7RAD) | last post: by
5 posts views Thread by Fabio R. | last post: by
3 posts views Thread by ssg31415926 | last post: by
4 posts views Thread by Sue | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.