all groups > asp.net security > may 2007 >
You're in the

asp.net security

group:

Membership & Profiles



Membership & Profiles A_Republican
5/25/2007 11:13:01 AM
asp.net security: I have a CreateUserWizard object on my page with some additional fields:
First Name, Last Name, etc, etc.

I store all these additional fields in a profile for the user. The problem
is if I use Membership.DeleteUser(...) it will delete the user from the User
table, but it will not remove their profile. I'm not sure why this is
happening. Could someone explain what I'm doing wrong?

--
Regards,
Shaun Goldston

Liberalism is treason!
RE: Membership & Profiles A_Republican
5/25/2007 11:18:01 AM
Re: Membership & Profiles Smartkid
5/27/2007 12:00:00 AM
(May be) this is the designed behavior of ASP.NET.
A quick (and dirty) workaround is to create a trigger in the 'users' table
or a delete cascade foreign key reference on the 'profile' table.


[quoted text, click to view]
Re: Membership & Profiles Dominick Baier
5/27/2007 12:00:00 AM
you are doing nothing wrong.

Just call ProfileManager.DeleteProfile in addition...


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

[quoted text, click to view]

Re: Membership & Profiles A_Republican
5/27/2007 4:54:00 PM
Okay maybe I just mis-understood the intelli-sense description.



--
Regards,
Shaun Goldston

Liberalism is treason!
Vote Republican


[quoted text, click to view]
Re: Membership & Profiles A_Republican
5/27/2007 6:11:01 PM
This is how I create a users profile:

Protected Sub CreateUserWizard_CreatedUser(ByVal sender As Object, ByVal e
As System.EventArgs) Handles CreateUserWizard.CreatedUser

ProfileBase.Create(Profile.UserName)

Profile.FirstName = CustomProfileInfo.FirstName
Profile.LastName = CustomProfileInfo.LastName
Profile.StreetAddress = CustomProfileInfo.StreetAddress
Profile.City = CustomProfileInfo.City
Profile.State = CustomProfileInfo.State
Profile.ZipCode = CustomProfileInfo.ZipCode
Profile.EmailAddress = CreateUserWizard.Email
Profile.HomePhoneNumber = CustomProfileInfo.HomePhoneNumber
Profile.CellPhoneNumber = CustomProfileInfo.CellPhoneNumber

End Sub


This is how I delete a user and their profile:

Private Function DeleteUser(ByVal strUserName As String) As Boolean
Dim blnResult As Boolean = False

'Delete the user and their profile
If blnResult = ProfileManager.DeleteProfile(strUserName) = True Then
If blnResult = Membership.DeleteUser(strUserName) = True Then
blnResult = True
End If
End If

Return blnResult
End Function


I have a GridView control that gets populated with every users profile
information. However, when I run my delete function for a user it doesn't get
deleted even though it says it was deleted. When I look in the database
(ASPNETDB) is still has their profile information and their membership
informatin.



This is off topic, but can someone tell me how to select the browser I want
to use from within VS 2005. Even though my default browser is IE, it always
RE: Membership & Profiles A_Republican
5/31/2007 3:00:01 PM
1. If I start from an empty database, and add two users to the membership
database, why does the second users profile overwrite the first users profile?

2. Why when I call ProfileManager.DeleteProfile(strUserName) does it not
actually delete the profile?

3. Lastly, why does it not remove the entry from the database when I call
Membership.DeleteUser()?






This is how I create a users profile:

Protected Sub CreateUserWizard_CreatedUser(ByVal sender As Object, ByVal e
As System.EventArgs) Handles CreateUserWizard.CreatedUser

ProfileBase.Create(Profile.UserName)

Profile.FirstName = CustomProfileInfo.FirstName
Profile.LastName = CustomProfileInfo.LastName
Profile.StreetAddress = CustomProfileInfo.StreetAddress
Profile.City = CustomProfileInfo.City
Profile.State = CustomProfileInfo.State
Profile.ZipCode = CustomProfileInfo.ZipCode
Profile.EmailAddress = CreateUserWizard.Email
Profile.HomePhoneNumber = CustomProfileInfo.HomePhoneNumber
Profile.CellPhoneNumber = CustomProfileInfo.CellPhoneNumber

End Sub


This is how I delete a user and their profile:

Private Function DeleteUser(ByVal strUserName As String) As Boolean
Dim blnResult As Boolean = False

'Delete the user and their profile
If blnResult = ProfileManager.DeleteProfile(strUserName) = True Then
If blnResult = Membership.DeleteUser(strUserName) = True Then
blnResult = True
End If
End If

Return blnResult
End Function




AddThis Social Bookmark Button