Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dears,

I was trying to access User.IsInRole("Administrator"). But it is always failing. Though i have records in the tables WebPages_Roles and WebPages_UserInRoles.

Any one please suggest what could be the issue

regards
Azeem
Posted
Comments
bbirajdar 1-Jun-13 6:00am    
"But it is always failing" is not a technical description of the problem.. I cannot understand the problem unless I see the code.. Wait till somebody transmits himself to your system via internet and he will then check the code and will probably figure out the issue
Ahamed Azeem 1-Jun-13 6:02am    
Thanks

1 solution

But ... Did you actually create the User? Remember that you must create a user object before you can access it. You may have validated a username and password but not created a user. :)

http://msdn.microsoft.com/en-us/library/ftx85f8x.aspx[^]

And this should help some too ...
http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/9bfb3edc-41e7-4126-b316-2fdee3dfdb11/[^]

http://msdn.microsoft.com/en-us/library/vstudio/ff851957.aspx[^]
 
Share this answer
 
v2
Comments
Ahamed Azeem 2-Jun-13 9:25am    
Dear Prissy,

Read my question again "Though I have records in the tables,,,,,"
PrissySC 2-Jun-13 9:55am    
No sweetheart, not in the tables ... Did you create the user object?


On login, you create the user prior to validating, therefore you should have a principal and identity class, which has nothing to do with whether or not you stored a user's information in a table in a database. From this point, the user is set by whether or not the validation failed. If you are using Lightswitch, most of this is handled in the setup. But ... you still need an instance of a user in order to use the call IsInRole :) HTH!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900