c# - Active directory cross domain - group members using PrincipalContext -


i trying fetch members of given active directory group using directoryservices.accounemanagement namespaces classes in c#.

if have principal context object constructor specified specific domain, whenever access member the group other domains running below error: "a referral returned server".

scenario : have different sub domains under root domain eg: emea.mycorp.com, asia.mycorp.com, asiapacific.mycorp.com, xyz.mycorp.com

if running below code domain xyz.mycorp.com, group in asiapacific if specify servername in principal context object access group.

private principalcontext context =      new principalcontext(contexttype.domain, "asiapacific domain server name"); 

if group has users other domains emea\abcd, below code fails @ userprincipal:

groupprincipal searchgroup = groupprincipal.findbyidentity(context, "dev team");      groupname = new list<string>();     foreach (userprincipal p in searchgroup.getmembers())           {                 groupname.add(p.samaccountname + " " + p.distinguishedname + " " + p.name);       } 

so, there way can pass context root domain, code work irrespective of domain user belongs to. tried below , none of luck:

private principalcontext context =      new principalcontext(contexttype.domain, "mycorp.com"); 

or

private principalcontext context =      new principalcontext(contexttype.domain, "dc=mycorp,dc=com"); 

try this:

new principalcontext(contexttype.domain, "xyz.mycorp.com:3268", "dc=mycorp,dc=com"); 

this create principalcontext using global catalog service on local domain controller (of course, assumes local dc gc well). allow searches of entire forest.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -