Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What is the Unique ID for Users in the ASPNETDB.MDF

Posted on 2011-03-22
4
Medium Priority
?
604 Views
Last Modified: 2012-05-11
What is the Unique ID for Users in the ASPNETDB.MDF and how can it be accessed through VB or C#?  Thanks.
0
Comment
Question by:jigdog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
_kiwi_ earned 2000 total points
ID: 35197085
Hello,

In this database, the unique ID for Users is an automatically generated GUID (Globally Unique IDentifier) stored in the UserId column of the aspnet_Users in the ASPNETDB.MDF (or any other source: SQL Express, ...) database.

You should never rely on this data directly but always use:
- User related functions: System.Web.Security.Membership class (e.g. Membership.GetUser() Gives you the logged-in user, with a ProviderUserKey property that is the GUID of this user)
- Role related functions: System.Web.Security.Roles class (e.g. Roles.IsUserInRole() tells you if the current user is in a particular role)
- Profile related functions: System.Web.Profile.ProfileManager class

--> Answer to the first question: to get the user ID: (Guid) System.Web.Security.Membership.GetUser().ProviderUserKey
This only works this way because it is ASPNetDB in the backend, it can be different with other Membership Providers.

Otherwise (**Highly not recommended**) you have a connectionString called "ApplicationServices" in your Web.Config that points to the database, and starting from the current user's guid you can query through SQL Queries the database, it is either an access or a plain SQL Database, you can mount it in Visual Studio and look through the data.

Hope this helps,
Julien
0
 

Author Comment

by:jigdog
ID: 35198790
Thank you for your answer.  Before I award points, could i ask:  is there a way to list all current users in the ASPNETDB?  
0
 
LVL 3

Expert Comment

by:_kiwi_
ID: 35199032
System.Web.Security.Membership.GetAllUsers() will get that for you.

An alternative exists that supports paging:
System.Web.Security.Membership.GetAllUsers(pageIndex, pageSize, out totalRecords)

Have a nice day,
Julien
0
 

Author Comment

by:jigdog
ID: 35199066
Wonderful, thanks for your help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question