mgmhicks
asked on
Accessing membership users and their profiles.
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
thanks
ASKER
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
thanks
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.
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.
ASKER
This is all I actually had to do. I might have made it more complicated then neccessary
Dim piColl As ProfileInfoCollection = ProfileManager.GetAllProfi les(Profil eAuthentic ationOptio n.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@theapartmentgaller y.com if you have forgotten your username."
Label9.Visible = True
Exit Function
Else
End If
Next
Dim piColl As ProfileInfoCollection = ProfileManager.GetAllProfi
Dim myprofile As ProfileCommon
Dim myInfo As ProfileInfo
For Each myInfo In piColl
myprofile = ProfileBase.Create(myInfo.
Dim mSSNUM As String = myprofile.ResidentDetails.
Dim mBirthdate As String = myprofile.ResidentDetails.
Dim mLastName As String = myprofile.ResidentDetails.
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@theapartmentgaller
Label9.Visible = True
Exit Function
Else
End If
Next
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.
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.
ASKER
Is there syntax in this statement
Dim piColl As ProfileInfoCollection = ProfileManager.GetAllProfi les(Profil eAuthentic ationOptio n.All)
to allow me to trim the profiles I look through?
Dim piColl As ProfileInfoCollection = ProfileManager.GetAllProfi
to allow me to trim the profiles I look through?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.