activedirectorymembership

Find current users active directory group C++

假装没事ソ 提交于 2019-12-04 20:34:40
How would I go about querying what active directory group the currently logged in user belongs to? I am assuming it will be through LDAP but I havnt been able to find much on how to get this particular information. I have put together some code but im not quite sure what I need to do next // Open the access token associated with the calling process. if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken) == FALSE) { dwErrorCode = GetLastError(); wprintf(L"OpenProcessToken failed. GetLastError returned: %d\n", dwErrorCode); return HRESULT_FROM_WIN32(dwErrorCode); } // Retrieve the token

PrincipalContext.ValidateCredentials always returns FALSE

白昼怎懂夜的黑 提交于 2019-12-03 10:30:33
I have an MVC application that needs to login and verify a user against Active Directory. I am using the PrincipalContext.ValidateCredentials method but always get a authentication of false . Connecting to the Server is fine. The problem seems to occur in the ValidateCredentials . Here is my code: public static bool IsAuthenticated(string domain, string username, string pwd) { bool IsAuthenticated = false; try { PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, domain, "DC=c1w,DC=com"); username = "c1w\\" + username; IsAuthenticated = insPrincipalContext

Query From LDAP for User Groups

坚强是说给别人听的谎言 提交于 2019-11-28 07:46:42
How To Get User group of user from LDAP active directory in C# .NET for ASP. In my Scenario I want to Pass user name to method which query from LDAP Active directory and tell me my user is Member of This User Groups. Please help me in this If you're on .NET 3.5 or newer, you can also use the new System.DirectoryServices.AccountManagement (S.DS.AM) namespaces. With this, you can do something like: // create context for domain PrincipalContext ctx = new PrincipalContext(ContextType.Domain); // find the user UserPrincipal up = UserPrincipal.FindByIdentity(ctx, "YourUserName"); if(up != null) { //