Exemple #1
0
    public void Run(Object source, EventArgs e)
    {
        // Get the reference of the application and context server classes
        HttpApplication application = (HttpApplication)source;
        HttpContext     context     = application.Context;

        // Get the current identity of the windows users
        var identity = WindowsIdentity.GetCurrent();
        var user     = identity.Name.Split("\\".ToCharArray());

        LdapSsoServiceClient ldapSsoServiceClient = new LdapSsoServiceClient();

        // Execute the service call to authenticate user
        AuthenticationResult result = ldapSsoServiceClient.AuthenticateUser(user[1], string.Empty);

        // Return the appropriate staus code - 200 - Success,  403 - Forbidden
        if (result != AuthenticationResult.SUCCESS)
        {
            HttpContext.Current.Response.Redirect("http://localhost:6011/Account/Index");
            HttpContext.Current.Response.StatusCode = 403;
        }
        else
        {
            // Execute the service call and get the user groups
            UserGroupDto userGroups = ldapSsoServiceClient.GetUserGroups(user[1]);

            // Persists the information in the session variables
            context.Items.Add("LoggedInUser", identity.Name);
            context.Items.Add("UserGroups", userGroups.GroupNames);

            HttpContext.Current.Response.StatusCode = 200;
        }
    }
        public ActionResult Index(UserLoginModel userLoginModel)
        {
            LdapSsoServiceClient ldapSsoClient = new LdapSsoServiceClient();

            AuthenticationResult ret = ldapSsoClient.AuthenticateUser(userLoginModel.UserName, userLoginModel.Password);

            return(new ContentResult()
            {
                Content = "The user has been successfully authenticated!,  Please navigate to the website again."
            });
        }