Connecting Tech Pros Worldwide Help | Site Map

User Roll & Security

Newbie
 
Join Date: Jul 2008
Posts: 21
#1: Jan 26 '09
Hi, and thanks for your time.
Using vb.net

I'm new to .net, recently moved from classic asp!
I'm creating an intranet web application that needs to keep a log of user activity.

What I would have done in classic ASP is to store the user ID from my user table in any new records. Then I could drill down from that as needed. But now with .net and its incorporated security features, I dont see how this approach is going to work!

I have seen examples of getting the current user name, but nothing about a name based on a user ID, or even how to get a user ID.

Could someone point me in the right direction as to how I would go about doing this kind of thing in .net.

I'm using forms based security.

Sorry if it's a bit vague, I'm rubbish at explaining myself.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#2: Jan 26 '09

re: User Roll & Security


I'm not sure what you are doing.
Have you configured your site to use Forms Authentication with Membership?

If so, a Principal Object is created to represent your user when ASP.NET detects a request for your website. This Principal Object is used to determine if the user is privileged to access certain pages and resources. In your page's you can retrieve it from the HttpContext.Current.User.Identity to determine what the user's name is.

Check out This Video about Membership.

Also, you should consider researching Forms Authentication, and Role Management so that you have a good idea of what happens during authentication and authorization.

-Frinny
Newbie
 
Join Date: Jul 2008
Posts: 21
#3: Jan 26 '09

re: User Roll & Security


Thanks Frinny. I found a really good set of articles hear, which has given some great examples of what can be done with regard to security. I also just took a look at the video link you provided. Very good, thanks. But...

... at the moment I'm more interested in being able to retrieve user information such as user name (not login name) and email address for example, but not necessarily for the currenty logged in user. I want to show details for users that may have made changes to the data!

Thanks

Tim
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#4: Jan 26 '09

re: User Roll & Security


What do you mean not 'not necessarily for the currently logged in user"?

If you are looking to display the history of data, you need to store that history somewhere. Store it in a Database, or XML file, or where ever you want to. When you want to display the data's history, retrieve the history from where it has been stored...

What exactly are you having problems with??
Newbie
 
Join Date: Jul 2008
Posts: 21
#5: Jan 26 '09

re: User Roll & Security


when a user saves a comment to an enquiry record in the database, I want to save a reference(primary key?) to that user along with it so that i know who did it. Obviously i wouldn't want to save the user name, telephone number and email address each time a user makes a comment.

So when i display a report that lists changes made to the database I need to be able to get the user name and email etc based on the user reference I saved.

Somthing like:

GetUserInfo("TimV").Email ....would return 'timv@whatever.com'
GetUserInfo("Bob").Telephone....would return '0898 444444'

And to make things worse, I will probably want to do this in a GridView... I'll cross that bridge when i come to it :)

Does that make a little more sence??
Newbie
 
Join Date: Jul 2008
Posts: 21
#6: Jan 27 '09

re: User Roll & Security


OK, I have made progress on this subject.
To retrieve sprecific user information (logged in or not):
Expand|Select|Wrap|Line Numbers
  1. Profile.GetProfile("Tim").FirstName
or
Expand|Select|Wrap|Line Numbers
  1. Membership.GetUser("Tim").Email
This has led me to a new problem. I will start a new thread for this... hope this helps someone ??
Reply


Similar ASP.NET bytes