I had a previous post about this topic, but I am still have a problem accessing user group from the active directory.
In a C# 2008 desktop application, I need change the application since all the users are moving from one domain to new domain. The current application does not let the user access information under the new domain name.
To accomplish this goal, I would like to see what roles have been setup for those users starting with myself.
I have tried the following items but they do not work or at least I do not know how to access the groups (roles) a user has access to:
To accomplish this goal, I would like to know how to access those roles.
1. Thread.CurrentPrincipal.Identity
2. System.Security.Principal.WindowsIdentity
Thus can you tell how I can access the groups/roles a user has access to from the items listed above?
If not, should I use the Active Directory (System.DirectoryServices.AccountManagement API) to find details about a user and the groups he's associated with? I would have to import System.DirectoryServices into my project and I would prefer not to use this option since this would not be permanent code.
Thus can you tell me ow show me in code how to accomplish this goal?
Loading
Nitesh KejriwalPosted Nov 2, 2012, 1:31 AM
http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.principalcontext.aspx
For a complete example, check here ...http://www.codeproject.com/Articles/38344/Using-System-DirectoryServices-AccountManagement
dcPosted Nov 1, 2012, 8:01 PM
If I am in correct, can you tell me what parameter values you gave in the routine you listed, can use some kind of a default value and which parameters? What other parameters do I need to actually determine what the value is?
Nitesh KejriwalPosted Nov 1, 2012, 5:57 PM
PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, "ServerName", "DomainController", "username", "password");
UserPrincipal UserProfile1 = UserPrincipal.FindByIdentity(insPrincipalContext, "userID");
UserProfile1.GetGroups()
http://msdn.microsoft.com/en-us/library/bb335571.aspx