How to find service accounts in Active Directory RRS feed

  • Question

  • Hi all,

    I want to find the Active Directory accounts which are service accounts (NPSA account)(Non-Person Specific Account) using C#.

    How can I do this ? I know we can get the AD user details using "System.DirectoryServices" namespace. I have a requirement where I have to find out all the service accounts created in Active Directory.

    How can I do this using c# code.

    Thanks for help.

    Thursday, January 28, 2016 4:46 AM


  • Hi Vishwajeet,

    I also don't find any C# method or library to help you get service accounts in Active Directory.

    But you could use the Active Directory module for Windows PowerShell to manage service accounts (and other objects). Common service account cmdlets include:
    New-ADServiceAccount creates a managed service account. By default, accounts are created in the Managed Service Account container in Active Directory (you can also specify an alternate OU for the new accounts).o Get-ADServiceAccount displays properties for managed service accounts.
    For more details, please refer to

    By the way, as far as I know, you can Executing PowerShell scripts from C#

    Here is a MSDN blog talk about this.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 28, 2016 7:34 AM