<pre lang="c#"> <pre>public static string AuthFunction_One(string identity, string password, string containerString, string adServerName, bool useLDAPS, IdentityType identityType) { string failedString = "FAILED"; string successString = "SUCCESS"; string returnValue = failedString; try { PrincipalContext ctx = null; if (useLDAPS) { ctx = new PrincipalContext(ContextType.Domain, adServerName, containerString, ContextOptions.Negotiate | ContextOptions.SecureSocketLayer); } else { ctx = new PrincipalContext(ContextType.Domain, adServerName, containerString); } UserPrincipal oUserPrincipal = UserPrincipal.FindByIdentity(ctx, identityType, identity); PrincipalSearchResult<Principal> oPrincipalSearchResult = oUserPrincipal.GetGroups(); try { foreach (Principal result in oPrincipalSearchResult) { } } catch (Exception ex) { NLogHelper.GetInstance().Log("ADUtilityClass", "AuthFunction_One", NLog.LogLevel.Debug, "Failed to probe groups. Ex: " + ex.ToString()); } if (ctx.ValidateCredentials(identity, password)) { return successString; } else { return failedString; } } catch (Exception ex) { NLogHelper.GetInstance().Log("ADUtilityClass", "AuthFunction_One", NLog.LogLevel.Debug, "Error in function. Ex: " + ex.ToString()); return failedString; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)