天天看點

ad被鎖定的賬戶,查詢AD帳戶以檢視是否已鎖定/解鎖

ad被鎖定的賬戶,查詢AD帳戶以檢視是否已鎖定/解鎖

Hi All, hoping someone can help. Trying to programme a console app where it asks you to enter a username, if the account is unlocked i want a console.writeline to say "Account is not locked"

If the account is locked i want it unlocking and another writeline to say "Account Unlocked"

i've looked into CMD commands and come across "net user xxxxx /domain /active:yes"  Not sure if this is included in the c# code

Any advise would be appreciated

Thanks

解決方案Use DirectoryServicesto find the user account and check the account status. Of course you'll need appropriate permissions as well. There is a subsection of the documentation on working with users. On the

IADsUserclass is a property indicating whether it is disabled or not.