Solved

Accessing membership users and their profiles.

Posted on 2009-05-14
7
243 Views
Last Modified: 2012-05-07
I have a login program and am using profiles to store data about each user.  What I need is a way to check against data that a new user being created is trying to give me with the information in the profiles table of existing users.  this is to make sure a single user can only add himself to the users database 1 time.  

thanks
0
Comment
Question by:mgmhicks
  • 4
  • 3
7 Comments
 
LVL 3

Expert Comment

by:Viwind
ID: 24392211
Hi mgmhicks,

When a new user is created, unique data shouldn't be part of profile but part of User object and in the properly configured table (with a unique index), you can prevent user from entering a new data from Database.

Such example would be "email" account.  If you store e-mail in Profile instead of actual user Email column/field in a table, you can set unique index to it prevent user to enter e-mail already entered.

Otherwise,  you will have to search for a specific data in profiles column.

If you want to write more code to check if e-mail already exists instead of catching exception, indexing data is a way to go as it'll retrieve data fast.  Unique index will be even faster.
0
 

Author Comment

by:mgmhicks
ID: 24393992
the information is stored in the profile, ie SSNum and Birthday.  I want to verify that the SSNUM and Birthday together I guess is not already in the system.  How do I uniquely set something in a profile.  The profile table basically has ID colulmn, PropertyNames column and then the data.  

thanks
0
 
LVL 3

Expert Comment

by:Viwind
ID: 24401850
Profile is stored into a text format by default.
You will have to send a query and retrieve data.  for example, you can use Like search in SQL script to check if same information SIN="XXX" and Birthday="YYYY/MM/DD" matchs exactly.

the trick is to find out the column and see if you can do a phrase search. If it's SQL server, make it a full-text indexed and do a phrase keyword search for the best performance.

Restriction or requirements are that all data should be formatted properly so the search can be performed.

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:mgmhicks
ID: 24407142
This is all I actually had to do.  I might have made it more complicated then neccessary
Dim piColl As ProfileInfoCollection = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)
            Dim myprofile As ProfileCommon
            Dim myInfo As ProfileInfo

            For Each myInfo In piColl
                myprofile = ProfileBase.Create(myInfo.UserName)
                Dim mSSNUM As String = myprofile.ResidentDetails.SSNum
                Dim mBirthdate As String = myprofile.ResidentDetails.Birthday
                Dim mLastName As String = myprofile.ResidentDetails.LName
                If mSSNUM = Trim(txtSSNum.Text) And mBirthdate = Trim(txtBirthDate.Text) And mLastName = Trim(txtLName.Text) Then
                    CheckUser = False
                    Label9.Text = "User already exists in the system.  Please contact support@theapartmentgallery.com if you have forgotten your username."
                    Label9.Visible = True
                    Exit Function
                Else
                End If
            Next
0
 
LVL 3

Expert Comment

by:Viwind
ID: 24407324
that is indeed over kill as there could be thousands of users in get all profiles.
the solution is not scalable as it gets all users and loops through where as searching is much faster; that you do not load all profiles.
0
 

Author Comment

by:mgmhicks
ID: 24407346
Is there syntax in this statement
Dim piColl As ProfileInfoCollection = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)

to allow me to trim the profiles I look through?

0
 
LVL 3

Accepted Solution

by:
Viwind earned 500 total points
ID: 24407446
is this a custom profile?
if not, then you can't find by profile content:
http://msdn.microsoft.com/en-us/library/system.web.profile.profilemanager_methods.aspx
if it's a custom profile, you can add a new functionality to check for other metada (sin, birthday etc.)
or from the code, you can just search for profile table (a hack ... we call it)

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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