开发者

Using IPrinciple.Identity.Name as a key in a dataBase to identify user's rows

开发者 https://www.devze.com 2022-12-29 13:35 出处:网络
I\'m writing a small intranet app that uses Windows Authentication and Asp.Net MVC. I need to sto开发者_StackOverflowre various bits of data in a db against each user.

I'm writing a small intranet app that uses Windows Authentication and Asp.Net MVC. I need to sto开发者_StackOverflowre 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消