Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Enumerate NT Group membership on remote computer

Enumerate NT Group membership on remote computer

Scheduled Pinned Locked Moved C#
csharphelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Harkamal Singh
    wrote on last edited by
    #1

    I need to enumerate members of Administrators group on all computers remotely. I should be able to specify computername, username & password. Has WMI got any class to enumerate group membership ? Also, has WinNT provider got capability to connect to remote machines with alternate credentials? Any code will be of great help. Thanks in anticiaptions. h.

    before c# there was darkness

    E 1 Reply Last reply
    0
    • H Harkamal Singh

      I need to enumerate members of Administrators group on all computers remotely. I should be able to specify computername, username & password. Has WMI got any class to enumerate group membership ? Also, has WinNT provider got capability to connect to remote machines with alternate credentials? Any code will be of great help. Thanks in anticiaptions. h.

      before c# there was darkness

      E Offline
      E Offline
      elibriscoe
      wrote on last edited by
      #2

      Hello. I've actually recently written a program to manage user groups on remote servers, including add an expiration date/time when that user will be removed. I'll be posting an article on it soon. Here is some code that should help you out. You will need to add a reference to System.DirectoryServices, and using statements for System.DirectoryServices and System.Collections: String entryString = "WinNT://" + computerName + ",computer"; DirectoryEntry dirEntry = new DirectoryEntry(entryString, username, password); foreach (DirectoryEntry entry in dirEntry.Children) {    if (entry.SchemaClassName.Equals("group", StringComparison.CurrentCultureIgnoreCase))    {       if (entry.Name.Equals("Administrators"))       {          object members = entry.Invoke("Members", null);          foreach (object member in (IEnumerable)members)          {             DirectoryEntry memberEntry = new DirectoryEntry(member);             String name = memberEntry.Name;             String path = memberEntry.Path;             MessageBox.Show(path + "\n" + name + "\n" + memberEntry.SchemaClassName);          }       }    } }

      H 1 Reply Last reply
      0
      • E elibriscoe

        Hello. I've actually recently written a program to manage user groups on remote servers, including add an expiration date/time when that user will be removed. I'll be posting an article on it soon. Here is some code that should help you out. You will need to add a reference to System.DirectoryServices, and using statements for System.DirectoryServices and System.Collections: String entryString = "WinNT://" + computerName + ",computer"; DirectoryEntry dirEntry = new DirectoryEntry(entryString, username, password); foreach (DirectoryEntry entry in dirEntry.Children) {    if (entry.SchemaClassName.Equals("group", StringComparison.CurrentCultureIgnoreCase))    {       if (entry.Name.Equals("Administrators"))       {          object members = entry.Invoke("Members", null);          foreach (object member in (IEnumerable)members)          {             DirectoryEntry memberEntry = new DirectoryEntry(member);             String name = memberEntry.Name;             String path = memberEntry.Path;             MessageBox.Show(path + "\n" + name + "\n" + memberEntry.SchemaClassName);          }       }    } }

        H Offline
        H Offline
        Harkamal Singh
        wrote on last edited by
        #3

        Hello there, The problem is that I need to connect with alternate credentials. All my servers have different password. WinNT provider by default uses pass-through authentication, which means takes your currently logged on priviledges to connect to remote computer. This works good if I have common password as I login using same passowrd. But that is very risky, a malicious code can then play aroumd. I am also trying to find out way to connect using alternate credentials, If you get to know first please post it :) By the way, there's option in directory entry class to specify user/password but in that case the output is blank, not sure why. Good day. h.

        before c# there was darkness

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups