I have a code sample like below
PrincipalContext context = new PrincipalContext(ContextType.Domain, "aaaaa", "aaaa\\bbb", "pppppp");
var group = GroupPrincipal.FindByIdentity(context, IdentityType.Guid, "253DD8F5-3C6E-438A-899F-8A693B0AD93E");
PrincipalSearchResult<Principal> users = group.GetMembers(true);
foreach (UserPrincipal user in users)
{
var a =user.Sid.Translate(typeof(NTAccount)).ToString();
}
I'm trying to use group to find its member. Some member come from other trusted forest ,so I can't use the 'member of' of user..
I have several server which's environment are server 2008 , 2008 R2 ,and 2012 etc...
The application can work well but some server will raise exception.
One is
System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated.
This one is because the sid can't be translate.....but other server is okay....
The other is
System.DirectoryServices.AccountManagement.PrincipalOperationException: While trying to resolve a cross-store reference, the SID of the target principal could not be resolved. The error code is 5.
And this one is because can't access the searching result