Unable to login windows 8 IE 10. Please help me. The sample code is given below.
<asp:Login ID="loginControl" FailureText="Invalid Login" runat="server" Width="100%"
OnLoggingIn="signInControl_LoggingIn" OnAuthenticate="signInControl_Authenticate"
BorderStyle="None">
<LayoutTemplate>
<table>
<tr>
<td>
<asp:Label runat="server" ID="Label1" Text="LoginID:-"></asp:Label>
</td>
<td>
<telerik:RadTextBox runat="server" ID="UserName">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Password:-"></asp:Label>
</td>
<td>
<telerik:RadTextBox runat="server" ID="password">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<telerik:RadButton runat="server" ID="login" Text="Sign In" commandname="Login" >
</telerik:RadButton>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
public class MYLoginPage : IdentityModelSignInPageBase
{
protected override void OnLoad(EventArgs e)
{
}
protected void signInControl_LoggingIn(object sender, LoginCancelEventArgs e)
{
}
protected void signInControl_Authenticate(object sender, AuthenticateEventArgs e)
{
SecurityToken token = null;
LoginControl formsLoginControl = sender as LoginControl;
if (null != (token = GetSecurityToken(formsLoginControl)))
{
EstablishSessionWithToken(token);
e.Authenticated = true;
base.RedirectToSuccessUrl();
}
}
private SecurityToken GetSecurityToken(LoginControl formsLoginControl)
{
SecurityToken token = null;
SPIisSettings iisSettings = IisSettings;
Uri appliesTo = base.AppliesTo;
if (string.IsNullOrEmpty(formsLoginControl.UserName) ||
string.IsNullOrEmpty(formsLoginControl.Password))
return null;
SPFormsAuthenticationProvider authProvider = iisSettings.FormsClaimsAuthenticationProvider;
token = SPSecurityContext.SecurityTokenForFormsAuthentication(
appliesTo,
authProvider.MembershipProvider,
authProvider.RoleProvider,
formsLoginControl.UserName,
formsLoginControl.Password);
return token;
}
private SPIisSettings IisSettings
{
get
{
SPWebApplication webApp = SPWebApplication.Lookup(new Uri(SPContext.Current.Web.Url));
SPIisSettings settings = webApp.IisSettings[SPUrlZone.Default];
return settings;
}
}
private void EstablishSessionWithToken(SecurityToken securityToken)
{
if (null == securityToken)
{
throw new ArgumentNullException("securityToken");
}
SPFederationAuthenticationModule fam = SPFederationAuthenticationModule.Current;
if (null == fam)
{
throw new ArgumentException(null, "FederationAuthenticationModule");
}
fam.SetPrincipalAndWriteSessionToken(securityToken);
}
}
No comments:
Post a Comment