views:

18

answers:

1

I'm writing a small intranet app that uses Windows Authentication and Asp.Net MVC. I need to store various bits of data in a db against each user. As far as I can tell the IPrinciple object does not seem to have something like a unique id. So I was thinking I could just use User.Identity.Name as a unique value to identify rows in my db. Is this a bad idea? Is there an alternative to this approach?

Thanks for any help.

+1  A: 

I would create a User table that included an identity column as the id. When a person accesses the site, I would check the user table for that individuals unique id, and read it if it exists, or insert a new row if the user is new.

Login names can be long, and that could affect your indexes depending on the expected size of your data.

NerdFury
Yes that what I was thinking - what I'm really asking though is what part of the IPrinciple.Identity object should I store in the db - i.e. what should I use to look up a user in the user table you descibed?Thanks for taking the time answer - much appreciated.
bplus