473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

HttpContext.Current.User returns null (forms authentification); how to use custom role and membership providers together?

There are tons of articles about custom role and provider membership,
but they just tear me apart and confuse :(

The situation is following: I use DB2, so I wrote custom role +
membership providers.
Membership provider seems to work. I use forms authentication, so as
articles say, I need to do some magic to be able to get roles for
current user, because microsoft mechanism works only for windows
authentication...

The articles are
http://www.howtodothings.com/compute...ith-roles.html
and
http://www.codeproject.com/aspnet/formsroleauth.asp

Ticket, hmm... I guess I don't need it, because I use login control
for authentication, I just need to get roles for the authenticated
user somewhere... where?? Do I need to create instance of my role
provider class?? There's no info about it on MSDN site. I've decided
to use first article approach, but WHERE to start from?
Why HttpContext.Current.User returns null? When should I create
application array for the roles?

My client waits until i'm done with login page, but I'm totally lost
in all this info....

Oct 31 '07 #1
4 8201
Ok, HTTPContext was null, because I checked it before going from login
page and there was no post request yet. But all in all - how correct
code should look like for custom membership provider to get roles (and
saving them for later use!) right after authentication and before
redirecting to other page??

Oct 31 '07 #2
Well... i can see i'm the quickest one :)))
So I got access to roleprovider via Roles and to my membershipuser
class via static call: mymembershipclass.getuser(), which returns a
new instance of mymembershipuser class... Then, being in global
context (LoggedIn even) i can save it for later use somewhere...

Oct 31 '07 #3
If you want to simplify things, role information can come out of your users
table (or a roles table with a JOIN) at the time the user is looked up for
authentication. This information is usually stored in the Forms ticket's
UserData field as a comma-delimited list of role names. This then gets
"stored" in the Forms cookie.

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"al*******@gmail.com" wrote:
There are tons of articles about custom role and provider membership,
but they just tear me apart and confuse :(

The situation is following: I use DB2, so I wrote custom role +
membership providers.
Membership provider seems to work. I use forms authentication, so as
articles say, I need to do some magic to be able to get roles for
current user, because microsoft mechanism works only for windows
authentication...

The articles are
http://www.howtodothings.com/compute...ith-roles.html
and
http://www.codeproject.com/aspnet/formsroleauth.asp

Ticket, hmm... I guess I don't need it, because I use login control
for authentication, I just need to get roles for the authenticated
user somewhere... where?? Do I need to create instance of my role
provider class?? There's no info about it on MSDN site. I've decided
to use first article approach, but WHERE to start from?
Why HttpContext.Current.User returns null? When should I create
application array for the roles?

My client waits until i'm done with login page, but I'm totally lost
in all this info....

Oct 31 '07 #4
Ok.
What is supposed under forms cookie? Is it just a hidden field to
store data between site page cross-posting?
Or it's a server-side data, that is unique for every user?

Besides this, where it's appropriate to store info when navigating
between pages?

p.s. I'm originally from ColdFusion, where also such variable areas,
as session, application, client exist. But here a lot of things are
different, so I just want to know a common practics of this in
ASP.NET :)

Nov 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: techsupport | last post by:
I have some experience with .NET Remoting, as well as ASP.NET 2.0, and have been wanting to remote a custom membership and profile provider. I want to take advantage of the new controls in ASP.NET...
1
by: Tarun Mistry | last post by:
Hi all, I am using the ASP.NET 2.0 security model to impliment user access control on my site. I have a few questions hopefully someone can answer: 1) From the encrypted ticket stored in the...
0
by: awrigley | last post by:
Hi An app that was chuntering away quite happily to itself had roles added to it. Just two: Admins and Subscribers. However, I seem to have mucked up when assigning the role provider in the...
2
by: mark4asp | last post by:
This is a simplified version of my site. There are Premium users who have access to the Premium directory. Anyone else attempting to access it should be logged and then redirected to the...
4
by: dgilbert | last post by:
I have a custom membership provider that I am using to authenticate users in a WCF web service hosted IIS. I want to be able to see any cookies that come across and save session variables, but I...
3
by: at_the_gonq | last post by:
Hello, I am hoping to get some guidance on the following scenerio: I have a password protected site where users have various permissions. Are sessions the best way of storing the user's id? ...
2
by: James Crosswell | last post by:
I have a custom role provider and custom membership provider in my ASP.NET app. These work fine on my local box. When deploying the app I'm getting the following error: Description: An error...
1
by: =?Utf-8?B?aGZkZXY=?= | last post by:
Hello, I have a web application that makes use of the SQL Membership and Role providers. My app has admin screens to manage users (membership), roles, and supplementary user data. I have just...
13
by: bproddu | last post by:
Hi, I'm using Forms authentication for my web app. I've a custom Principal class that I would like to set to the HttpContext.Current.User after the Membership.ValidateUser() passes. I'm able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.