Note that there are some explanatory texts on larger screens.

plurals
  1. POFBA dual authentication problem
    text
    copied!<p><strong>What I have?</strong></p> <p>I have configured FBA in one of the web applications with out of the box login page having dropdown box to select the either windows or FBA login. Everything is working fine.</p> <p><strong>What I want?</strong></p> <p>I want to have a custom login page having text boxes for Username and Password and a login button which will be used for authenticating both Windows and FBA users. To distinguish between the two different logins, I want to handle OnAuthenticate event and check if the user name contains a '\' then assume it is Windows user otherwise, it is FBA user.</p> <p>This is the code written in OnAuthenticate event handler:</p> <pre><code>protected void signinControl_Authenticate(object sender, AuthenticateEventArgs e) { string fullUserName = signinControl.UserName; string username = null; if (fullUserName.Contains("\\")) //Windows user { string domain = fullUserName.Substring(0, fullUserName.IndexOf("\\")); using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domain)) { username = fullUserName.Substring(fullUserName.IndexOf("\\") + 1); e.Authenticated = pc.ValidateCredentials(username, signinControl.Password); } } else //FBA user { e.Authenticated = Membership.ValidateUser(fullUserName, signinControl.Password); } } </code></pre> <p><strong>What problem am I facing?</strong></p> <p>The code above works well for FBA Users. But, when I try to login with a windows user, even though the <code>e.Authenticated</code> is set <code>true</code> after validating, it is throwing this error: "Your login attempt was not successful. Please try again.".</p> <p><code>e.Authenticated = pc.ValidateCredentials(username, signinControl.Password);</code></p> <p>I believe that, setting <code>e.Authenticated</code> to <code>true</code> should redirect the user from login page to the requested page. Can someone please help me if I have to do anything else to get Windows user signed in?</p> <p><strong>Update-1</strong>:</p> <p>I used <code>SetAuthCookie()</code> method to set Cookie explicitly, still the same result. </p> <pre><code>FormsAuthentication.SetAuthCookie(username, true); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload