October 24th, 2013, 09:36 AM
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.
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)
I am new to python, hence want to know if this is possible in python.
groupQuery = "Select * from Win32_GroupUser Where PartComponent=\""+pathComponent+"\""
I was able to do the same in C#
Here's the C# code:
Thanks for any help
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domain name");
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "user name");
var groups = user.GetGroups(ctx);
October 24th, 2013, 03:36 PM
Found the code , just in case anybody is interested.
groups = win32net.NetUserGetGroups(server,"user name")