Membership.GetUser Not Working

Posted by Community Admin on 03-Aug-2018 20:16

Membership.GetUser Not Working

All Replies

Posted by Community Admin on 14-Mar-2011 00:00

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.

Posted by Community Admin on 15-Mar-2011 00:00

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

Posted by Community Admin on 15-Mar-2011 00:00

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

Posted by Community Admin on 15-Mar-2011 00:00

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

Posted by Community Admin on 15-Mar-2011 00:00

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

Posted by Community Admin on 15-Mar-2011 00:00

Hi Pik,

Separate oout and status - out status

msdn.microsoft.com/.../t3c3bfhx(v=vs.80).aspx

Kind regards,
Ivan Dimitrov
the Telerik team

Posted by Community Admin on 15-Mar-2011 00:00

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

Posted by Community Admin on 16-Mar-2011 00:00

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

Posted by Community Admin on 23-Mar-2011 00:00

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

Posted by Community Admin on 29-Mar-2011 00:00

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

This thread is closed