More in this section

Forums / General Discussions / Membership.GetUser Not Working

Membership.GetUser Not Working

10 posts, 0 answered
  1. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    14 Mar 2011
    Link to this post

    I am getting the following error message when I tried to use Membership.GetUser() in my code. Any idea why? Thanks, ~Pik

    You are not authorized to 'Manage Users' ('Backend').

    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.UnauthorizedAccessException: You are not authorized to 'Manage Users' ('Backend').

    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Mar 2011
    Link to this post
    Hello Pik,

    You use an anonymous user or the user you authenticated does not have Manage Users rights. Please grant the user you used to authenticate with Manage Users rights.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
  3. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    15 Mar 2011
    Link to this post
    Thanks for the reply.

    I went to the database to change the admin's password and then set the password_format to 0. When I try to login to the administration page, I keep getting the following error message:

    Incorrect Username/Password Combination
     

    Can you please tell me how to fix it?
    Thx, ~Pik

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Mar 2011
    Link to this post
    Hi Pik,

    Create a page in the root of the project. Inside Page_Load you can add the code below ( add the needed references and change the parameters for the user name if  you want)

    var userManager = UserManager.GetManager("Default");
    System.Web.Security.MembershipCreateStatus status;
    userManager.Provider.SuppressSecurityChecks = true;
     
    var user = userManager.CreateUser("user1", "user111@", "user1@test.com", "Question", "Answer", true, null, outstatus);
     
    user.FirstName = "FirstName";
    user.LastName = "LastName";
    userManager.SaveChanges();
     
      
       
     
    RoleManager roleManager = RoleManager.GetManager("AppRoles");
    roleManager.Provider.SuppressSecurityChecks = true;
    var role = roleManager.GetRole("Administrators");
    roleManager.AddUserToRole(user, role);
    roleManager.SaveChanges();

    Then build the project and open the page. After that you should be able to access the backend with the user
    created by  userManager.CreateUser .



    Regards,
    Ivan Dimitrov
    the Telerik team
  5. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    15 Mar 2011
    Link to this post
    I created a new page called Default2.aspx then right click select "Build Page". I am getting the following error message:

    The name 'outstatus' does not exist in the current context

    Thanks,
    ~Pik
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Mar 2011
    Link to this post
    Hi Pik,

    Separate oout and status - out status

    http://msdn.microsoft.com/en-us/library/t3c3bfhx%28v=vs.80%29.aspx

    Kind regards,
    Ivan Dimitrov
    the Telerik team
  7. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    15 Mar 2011
    Link to this post
    Thank you. It is working now.

    I would like to change the password format to clear. I went to Administration > Settings > Advanced > Security > ... > passwordFormat to change the value to clear. It does not seem to work.

    Can you please tell me how to do that?

    Thanks, ~Pik
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    16 Mar 2011
    Link to this post
    Hello Pik,

    You have to restart the application. Also the clear format will be available for the newly created users - after the configuration changes.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
  9. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    23 Mar 2011
    Link to this post
    I've set the passwordFormat to clear and restart the application. When I created a new user with password (user111@), below is the password in sf_users table. Why it is not user111@? What did I do wrong?

    user111@8103606714441141807C748160500615

    Thanks,PIk
  10. Sonya
    Sonya avatar
    205 posts
    Registered:
    09 Dec 2016
    29 Mar 2011
    Link to this post
    Hello Pik Lee,


    You are right - unfortunately the problem you have experienced with the passwordFormat is a bug. The issue is logged in our system with ID - 112009 and forwarded for fixing.

    I updated your Telerik points.

    Greetings,
    Sonya
    the Telerik team
10 posts, 0 answered