Solved

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

Posted on 2011-03-22
4
597 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp Google Map 2 64
Where does legacy ASP.NET initialize language? 2 63
Need help converting bitmap to image in VB.Net 8 46
Securing WEBAPI on Azure 2 28
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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.

726 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