#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    How to get groups of a user from a domain that is not the primary domain


    I want to query the domain(not the primary dc) to get all groups that a user belongs to.

    Code:
    win32net.NetUserGetGroup
    this will only let you query users of Primary DC.

    I have tried using WMI querying to achieve the same results but it is very slow.(like 20 mins)
    Code:
    groupQuery = "Select * from Win32_GroupUser Where PartComponent=\""+pathComponent+"\""
    I am new to python, hence want to know if this is possible in python.

    I was able to do the same in C#
    Here's the C# code:
    Code:
    PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domain name");
    
    UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "user name");
    
    var groups = user.GetGroups(ctx);
    Thanks for any help
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0
    Found the code , just in case anybody is interested.

    Code:
    server=str(win32net.NetGetDCName("","doamin name"))
    groups = win32net.NetUserGetGroups(server,"user name")

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo