Hi everybody,
I have problems with UserPrincipal.GetGroups() and GetAuthorizationGroups() method. Sometimes it works, sometimes not. The problem is that in the unsuccesfull cases the method contacts bad AD domain. My dev PC is connected to company
domain and I want to get groups for user in other, test domain, where the PC isn't in.
My code:
var ctx = new PrincipalContext(ContextType.Domain, "testdomain.int", "user1@test.int", "pwd123");
ctx.ValidateCredentials("user1@test.int", "pwd123"); //returns always true
var adUser = UserPrincipal.FindByIdentity(ctx, IdentityType.UserPrincipalName, "user1@test.int");
var groups = adUser.GetAuthorizationGroups(); //sometimes exception...
It raises ActiveDirectoryServerDownException - RPC server is unavailable. It is because
in this case the method call wanted to communicate with a company DC server, not with the
test domain!
My dev environment:
server:
- DC+DNS server W2003, single-DC domain "test.int",
- this DNS has "company.int" DNS as its forwarders, but same problem, if the forwarders are disabled.
my PC:
- connected to "company.int" domain
- uses only DNS server of the test DC
- same LAN network as the server
I didn't found way, how to force to always connect to the test DC server.