Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining User information outside of Page 1

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
0
0
GB
I have the need to establish whether the current user is in a role (using 'IsInRole("ADMIN")') in one of my code classes.
However given I'm outside of the 'Page' object I can't use the code Page.User.IsInRole("ADMIN") for example.

How can I achieve this?
Thanks in advance.
Steve
 
I am not sure what you are asking. The IsInRole() method is not specific to a page. Can you be more specific or post some code on what you are trying to do?
 
When I'm inside the scope of a web form (i.e. visual form with asp net Buttons, TextBoxes, etc. on it) - I'm able to make use of Page.User.IsInRole("ROLE") syntax.

However, when I'm in a standard class (i.e. 'Class1.cs') I am unable to use this syntax.

How can I access the current 'User' object via code in 'Class.cs'?
 
you can also get the user this way
WindowsPrinciple.Current.IsInRole("...");
this is web agnostic (although requires windows authentication, i think)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top