asp.net - Check if user exist in LDAP before authorization -
i use asp.net identity 2.0 , ldap authentication in mvc project , loing method shown below. @ first step check if user authenticated in ldap, need detect if there no user in ldap or credentials wrong return correct message user. how can this?
[httppost] [allowanonymous] [validateantiforgerytoken] public async task<actionresult> login(loginviewmodel model, string returnurl) { if (!modelstate.isvalid) { return view(model); } applicationgroupmanager groupmanager = new applicationgroupmanager(); // validate user using ldap if (membership.validateuser(model.username, model.password)) { formsauthentication.setauthcookie(model.username, model.rememberme); // formsauthentication.setauthcookie(model.username, false); //code omitted brevity if (this.url.islocalurl(returnurl) && returnurl.length > 1 && returnurl.startswith("/") && !returnurl.startswith("//") && !returnurl.startswith("/\\")) { return this.redirect(returnurl); //return redirecttolocal(returnurl); } return this.redirecttoaction("index", "issue"); } else { modelstate.addmodelerror("", "wrong credentials"); return this.view(model); } }
Comments
Post a Comment