Example #1
0
        public static bool UserExists(string windowsUserName)
        {
            try
            {
                using (var ctx = new PrincipalContext(ContextType.Domain, LdapServer, LdapComponent))
                {
                    var user = UserPrincipal.FindByIdentity(ctx, windowsUserName);

                    if (user != null)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.Debug(windowsUserName + " is not authorized!! (" + ex.Message + ")");
                return(false);
            }
        }