Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I was trying to retrieve the value of "userAccountControl".The reason for that is

userAccountControl= "512" for active and "514" for inactive user.

am going to use this preoperty in my filter to retrieve only Active users from AD.

when i use "userAccountControl" in my code,it doesn't return any value.please guide me,am i using the right property and name ?

Thanks in Advance
Posted

DirectoryEntry d = new DirectoryEntry("LDAP://" + ["distinguishedName"]);
int uac = (int)d.Properties["userAccountControl"].Value

have you tried this?
 
Share this answer
 
v2
Comments
shan1395 23-Feb-11 7:51am    
Thanks philip,def this works (haven't yet test in my end),i will let you know shortly after test from my end.Am going to use this function in my existing dll file and retrieve only active users.
Read the Community Comment section at the bottom of this page[^].
 
Share this answer
 
Hi,

can you use "UserPrincipal" to test if a user account is active?
http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal.aspx
 
Share this answer
 
Comments
shan1395 23-Feb-11 7:00am    
Hi Philip,

Thanks for your response,i don't think so "UserPrincipal" will tell you the account is active or not.
Pardon me if am wrong,i was going thru msdn (suggested by you),it doesn't help me much.Usally "UserAccountcontrol" tells you the account is active or deactive (based on 512 or 514).But in my case i was trying to retrieve the value from AD,but its not returning anything.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900