0

I have a website I'm developing and have roles setup with one group "admin" that I want to be able to select a user and display information about that user...name, password, security question and so on. What would be the easiest way to get this done? Also, I have modified the default login steps to include a few additional requirements, such as first and last name, company, etc. I would like the "admin" group to be able to view all this information quickly and easily so if a customer from another company calls us saying they fired that person, we can remove the user based on their actual name, not username.

EDIT Can I do something like:

MembershipUser user = System.Web.Security.Membership.GetUser(RegisterUser.UserName);
user.Comment = fnametxt.Text.ToString() + " " + lnametxt.Text.ToString() + " " + companytxt.Text.ToString();
System.Web.Security.Membership.UpdateUser(user);

to store the additional info then recall the user.Comment from the sql database when needed?

Jim S.
  • 203
  • 8
  • 24
  • What part exactly are you having trouble with? Where are the users/roles data being stored? This look like a fairly straightforward, standard spec that should be relatively easy to implement – mellamokb Sep 04 '12 at 12:51
  • I should have added I'm fairly new to asp.net. I know how to get the username of current users, where would I store the additional information that contains their first and last names and their company name? – Jim S. Sep 04 '12 at 12:56
  • You should use a Profile Provider to store the additional info. – Forty-Two Sep 04 '12 at 13:48

2 Answers2

1

Ok, you haven't said "Where" you're storing your membership information but I'll assume it's in a SQL DAtabase using the out-of-the-box Membership & RoleProvider schema that's generating by aspnet_regsql.exe

Aside from using the built-in user configuration tool in an ASP.NET Website, there are a few 3rd party applications you can use to interact with your membership users.

I used MyWSAT a long time ago but it doesn't appear to be maintained any more.

One thing you should be aware of, is that you can't & shouldn't be able to display the "password" of an end-user in your system.

Eoin Campbell
  • 43,500
  • 17
  • 101
  • 157
0

It would appear that what you are looking for is a Profile provider. This can be used to store addition information about users such as first and last names and other miscellanea.

in Web.config

<profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider"
             type="System.Web.Profile.SqlProfileProvider"
             connectionStringName="yourConnectionString"<!--Same as membership provider-->
             applicationName="/"/>
      </providers>
      <properties>
        <add name="FirstName" type="string"/>
        <add name="LastName" type="string"/>
        <add name="Company" type="string"/>
      </properties>
    </profile>

Add/edit profile properties:

var username = User.Identity.Name;
ProfileBase profile = ProfileBase.Create(username);
profile["FirstName"] = "John";
profile["LastName"] = "Smith";
profile["Company"] = "WalMart";
profile.Save();

Read profile properties:

var username = User.Identity.Name;
var profile = ProfileBase.Create(username);
var firstName = profile["FirstName"] as string;
var lastName = profile["LastName"] as string;
var company = profile["Company"] as string;

I think this would be the way to go and a bit cleaner and easier to maintain that using comments.

Forty-Two
  • 7,535
  • 2
  • 37
  • 54