+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Programmatic Login: Value too large/small for Int32

Programmatic Login: Value too large/small for Int32

6 posts, 0 answered
  1. Raymond Dowe
    Raymond Dowe avatar
    37 posts
    Registered:
    10 Mar 2010
    22 Jul 2015
    Link to this post

    I'm in the process of upgrading an application from Sitefinity 3.7 to 8.4. Everything has gone well so far, and we're now upgrading all of our existing functionality to work within the new version of Sitefinity. 

    I'm having a strange problem with programmatic login. There is a feature in the backend of the site where an administrator can view orders including the details of the user who purchased them. They have access to a button that, with a single click, will log them in as the user who made the purchase. They can then use the frontend site logged in as the user who made that purchase.

    Clicking the button works fine. However, when I go back to an admin page, I expect to see the Sitefinity backend login screen as they're logged in as a user who doesn't have administrator access. Instead, I'm getting this error:

     

    Server Error in '/' Application.

    Value was either too large or too small for an Int32.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.OverflowException: Value was either too large or too small for an Int32.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace: 


    [OverflowException: Value was either too large or too small for an Int32.]
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +10896403
       System.Convert.ToInt32(String value) +43
       Telerik.Sitefinity.Security.Claims.SWT.SWTParser.get_ExpiresOn() +114
       Telerik.Sitefinity.Security.Claims.SWT.SimpleWebToken.EnsureProperties() +94
       Telerik.Sitefinity.Security.Claims.SWT.SWTSecurityTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor) +1220
       Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.Issue(IClaimsPrincipal principal, RequestSecurityToken request) +426
       Telerik.Sitefinity.Security.Claims.ClaimsResolver.BuildSimpleWebToken(IClaimsPrincipal principal, String realm) +235
       Telerik.Sitefinity.Security.Claims.SFClaimsAuthenticationManager.RedirectToLogoutPage(String logoutMethod, HttpContextBase context, IClaimsPrincipal rejectedPrincipal, IEnumerable`1 removeParams, String returnUrl) +41
       Telerik.Sitefinity.Security.Claims.SFClaimsAuthenticationManager.RedirectToNeedAdminRightsPage(HttpContextBase context, IClaimsPrincipal principal) +54
       Telerik.Sitefinity.Security.Claims.SitefinityClaimsAuthenticationModule.Telerik.Sitefinity.Security.Claims.ISitefinityClaimsAuthenticationModule.RedirectToNeedAdminRightsPage(HttpContextBase context, IClaimsPrincipal principal) +9
       Telerik.Sitefinity.Security.Claims.ProtectedRoute.GetRouteData(HttpContextBase httpContext) +389
       System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +233
       System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60
       System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237

  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    27 Jul 2015
    Link to this post
    Hello,

    Thank you for contacting us.

    Clear the cookies on the browser where the test is performed and then perform the same steps that lead to the error again.

    If this produces no results and the issue still persist please let me know additional details for the users which encounter the issue. Are those users stored in Sitefintiy default user provider or those users are pulled from external user provider like LDAP?

    Regards,
    Stanislav Velikov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Raymond Dowe
    Raymond Dowe avatar
    37 posts
    Registered:
    10 Mar 2010
    31 Aug 2015
    Link to this post

    Just getting back to this now. The issue is still occurring.

    The users are from an older version of sitefinity 3.7 that was upgraded using the migration tools. They're in a provider  named "OpenAccessMembership37Provider".

    It's on a site where we're doing programmatic login as different users. An admin sometimes needs to impersonate other users to perform actions in the system on their behalf. There is a button an admin can click that will log them in as a given user:

     

    protected void lb_impersonateUser_Click(Object sender, EventArgs e)
    {
        Session["adminUser"] = GetCurrentUser().Id.ToString();
        Boolean success = AuthenticateUser(lit_email.Text.Trim().ToString());
        if (success)
        {
            Response.Redirect("/Subscription/Profile.aspx");
        }
    }
     
    public static User GetCurrentUser()
    {
        User user = null;
        var identity = ClaimsManager.GetCurrentIdentity();
        if (identity != null && identity.UserId != Guid.Empty)
        {
            UserManager userManager = UserManager.GetManager("OpenAccessMembership37Provider");
            user = userManager.GetUser(identity.UserId);
        }
        return user;
    }
     
    public Boolean AuthenticateUser(String username)
    {
        Boolean success = false;
        UserManager userManager = UserManager.GetManager("OpenAccessMembership37Provider");
        User user = null;
        UserLoggingReason validate = Telerik.Sitefinity.Security.SecurityManager.AuthenticateUser("OpenAccessMembership37Provider", username, false, out user);
        if (validate == UserLoggingReason.Success)
        {
            success = true;
        }
        return success;
    }

  4. Raymond Dowe
    Raymond Dowe avatar
    37 posts
    Registered:
    10 Mar 2010
    31 Aug 2015
    Link to this post

    I should say, when impersonating a user everything works fine. However, when I go back to the /Sitefinity page to login, if I haven't hit sign out first, I get the following error:

     

    Server Error in '/' Application.

    Value was either too large or too small for an Int32.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.OverflowException: Value was either too large or too small for an Int32.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace: 

    [OverflowException: Value was either too large or too small for an Int32.] System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +11013607 System.Convert.ToInt32(String value) +43 Telerik.Sitefinity.Security.Claims.SWT.SWTParser.get_ExpiresOn() +114 Telerik.Sitefinity.Security.Claims.SWT.SimpleWebToken.EnsureProperties() +94 Telerik.Sitefinity.Security.Claims.SWT.SWTSecurityTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor) +1220 Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.Issue(IClaimsPrincipal principal, RequestSecurityToken request) +426 Telerik.Sitefinity.Security.Claims.ClaimsResolver.BuildSimpleWebToken(IClaimsPrincipal principal, String realm) +235 Telerik.Sitefinity.Security.Claims.SFClaimsAuthenticationManager.RedirectToLogoutPage(String logoutMethod, HttpContextBase context, IClaimsPrincipal rejectedPrincipal, IEnumerable`1 removeParams, String returnUrl) +41 Telerik.Sitefinity.Security.Claims.SFClaimsAuthenticationManager.RedirectToNeedAdminRightsPage(HttpContextBase context, IClaimsPrincipal principal) +53 Telerik.Sitefinity.Security.Claims.SitefinityClaimsAuthenticationModule.Telerik.Sitefinity.Security.Claims.ISitefinityClaimsAuthenticationModule.RedirectToNeedAdminRightsPage(HttpContextBase context, IClaimsPrincipal principal) +9 Telerik.Sitefinity.Security.Claims.ProtectedRoute.GetRouteData(HttpContextBase httpContext) +385 System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +233 System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60 System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248

  5. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    03 Sep 2015
    Link to this post
    Hi,

    The problem occurs because the expiration of the toke/cookies is set to -62135593200 which in turn fails to convert to Int32, changing that to Int64 fixes the issue. This issue is fixed in the latest internal build for Sitefintiy 8.0 (8.0.5720).

    If you clear the browser cookies the issue will be avoided.

    Regards,
    Stanislav Velikov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  6. Nav
    Nav avatar
    0 posts
    Registered:
    07 Mar 2013
    7 hours ago in reply to Stanislav Velikov
    Link to this post

    Hello - We are getting same exception as above. We are using 8.0.5710.0  version of sitefinity. Please advise how we can address this issue.

     

    Server Error in '/' Application.

    Value was either too large or too small for an Int32.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.OverflowException: Value was either too large or too small for an Int32.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace: 

    [OverflowException: Value was either too large or too small for an Int32.] System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +11013607 System.Convert.ToInt32(String value) +43 Telerik.Sitefinity.Security.Claims.SWT.SWTParser.get_ExpiresOn() +114 Telerik.Sitefinity.Security.Claims.SWT.SimpleWebToken.EnsureProperties() +94 Telerik.Sitefinity.Security.Claims.SWT.SWTSecurityTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor) +1220 Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.Issue(IClaimsPrincipal principal, RequestSecurityToken request) +426 Telerik.Sitefinity.Security.Claims.ClaimsResolver.BuildSimpleWebToken(IClaimsPrincipal principal, String realm) +235 Telerik.Sitefinity.Security.Claims.SFClaimsAuthenticationManager.RedirectToLogoutPage(String logoutMethod, HttpContextBase context, IClaimsPrincipal rejectedPrincipal, IEnumerable`1 removeParams, String returnUrl) +41 Telerik.Sitefinity.Security.Claims.SFClaimsAuthenticationManager.RedirectToNeedAdminRightsPage(HttpContextBase context, IClaimsPrincipal principal) +54 Telerik.Sitefinity.Security.Claims.SitefinityClaimsAuthenticationModule.Telerik.Sitefinity.Security.Claims.ISitefinityClaimsAuthenticationModule.RedirectToNeedAdminRightsPage(HttpContextBase context, IClaimsPrincipal principal) +9 Telerik.Sitefinity.Security.Claims.ProtectedRoute.GetRouteData(HttpContextBase httpContext) +387 System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +233 System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +60 System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

6 posts, 0 answered