1

I have an application that i am building in lightswitch and created the user roles and authentication for them. in my database, i have all aspnet security tables. Now in aspnet_Users where i have all my users and aspnet_memebership with relevant info. I need to add a field to either table (which ever you guys recomend) to capture additonal info, i.e Country. My intention is that when using my code in asp.net application i can get the country for a user. similar to how i can get the identity name for a user with the following code.

EDITED I know how to add the field in the table, what i dont know is how to get to access the field using User.Identity... I would like my new field to show up in code.

sorry if there was any misunderstanding.

Application.Current.User.Identity.Name;

I would like to achieve something similar for the person country like:

Application.Current.User.Identity.Country
Maverick1415
  • 103
  • 1
  • 11
  • Are you asking how to add this column to a table, or are you asking which table would be the best to add this column to? – Jerreck Nov 26 '13 at 17:22
  • I don't know enough about this to post an answer, but I'm 99% certain that Application.Current.User.Identity.Country will not work because it does not exist as an object (User.Identity.Country is a pre-built object found within one of the System assemblies). So, you will have to create this object as well as the methods that it uses to connect to your database and retrieve the data you want. Check out these links: http://msdn.microsoft.com/en-us/library/bb386940(v=vs.110).aspx http://stackoverflow.com/questions/4002323/creating-a-database-query-method/4002709#4002709 – Jerreck Nov 26 '13 at 18:03

1 Answers1

0

Sounds like you need to implement a Custom Membership User along with a Custom Membership Provider in order to access additional properties.

Then you would need to use MembershipProvider.GetUser().Country to retrieve the property (where MembershipProvider is the name of your membership provider).

If you do want to access Application.Current.User.Identity.Country then you could create your own class that inherits from System.Security.Principal.IIdentity and then cast Application.Current.User.Identity to your own type before accessing the property.

SilverlightFox
  • 28,804
  • 10
  • 63
  • 132