I have an ASP.NET application which relies heavily on AD authentication. We recently broke out a service which used to live in the same solution as the application into its own solution, so that we could maintain them seperately and not impact users who rely on the service when, say, [...] read more
I'm using System.DirectoryServices.AccountManagement to query for a user and then find the groups for that user. var _principalContext = new PrincipalContext(ContextType.Domain, domainAddress, adContainer, adQueryAccount, adQueryAccountPassword); var user = UserPrincipal.FindByIdentity(_principalContext, IdentityType.SamAccountName, account); var userGroups = user.GetGroups(); foreach (var group in userGroups.Cast<GroupPrincipal>()) { ////////////////////////////////////////////////////// // getting the underlying DirectoryEntry shown // to [...] read more
I have a simple setup below to search for users. DirectoryEntry rootEntry = new DirectoryEntry("LDAP://someserver:123/OU=d-users,DC=domain,DC=x,DC=y,DC=com"); rootEntry.AuthenticationType = AuthenticationTypes.None; string filter = "sAMAccountName=" + AccountName; DirectorySearcher searcher = new DirectorySearcher(rootEntry, filter); SearchResult foundUser = searcher.FindOne(); For some reason I can search via a simple Console/windows forms app but cannot search from [...] read more