Help get this topic noticed by sharing it on Twitter, Facebook, or email.

ASP.NET Membership & Auto Create UserOrg Record

I am using ASP.NET Membership in a multi-tenant application with these details.

* Each Organization has a unique OrgID
* The UserOrgs table links users to the Organization

When creating a new user I want to specify the Organization to which they belong and automatically insert a new row into UserOrgs with the OrgID and UserId from the aspnet_Membership or aspnet_Users table.

Can the ASP.NET Membership provider be extended to add one data element (OrgID) to be entered when creating a new user and then have a trigger to run a stored procedure to make the insert into UserOrgs?

Does anyone have suggestions how this can be accomplished?
1 person has
this question
+1
Reply
  • Hi Jeffrey
    I stand to be corrected but from what I have read you can extend ASP NET membership if you have the unlimited version. I too wanted something similar but without the trigger to insert the additional record. In my case I wanted to record three additional fields when a user was added with one of those fields being an OrgID. With some help from Dennis (COT) I was able to achieve this by inserting some additional code. I won’t be home until tonight when I can check the code. Will post it and hopefully it will get you started. In the meantime someone else may have some other ideas.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Hi Jeffery

    Hopefully the below is of some use to you. I have it in a file called "MyProfileBusinessRules.Overide.vb"
    I am actually saving 4 additional fields of information against the user.

    Protected Overrides Sub SignUpUser(ByVal username As String, ByVal password As String, ByVal confirmPassword As String, ByVal email As String, ByVal passwordQuestion As String, ByVal passwordAnswer As String)
    MyBase.SignUpUser(username, password, confirmPassword, email, passwordQuestion, passwordAnswer)
    Dim firstName As String = CStr(SelectFieldValue("FirstName"))
    Dim lastName As String = CStr(SelectFieldValue("LastName"))
    Dim OrgNameIDFK As String = CStr(SelectFieldValue("OrgNameIDFK"))
    Dim CountryIDFK As String = CStr(SelectFieldValue("CountryIDFK"))
    Dim user As MembershipUser = Membership.GetUser(username)
    If user IsNot Nothing Then
    SqlText.ExecuteNonQuery("update YourTableName set FirstName = @p0, LastName = @p1, OrgNameIDFK = @p2, CountryIDFK = @p3 where UserID = @p4",
    New With {.p0 = firstName, .p1 = lastName, .p2 = OrgNameIDFK, .p3 = CountryIDFK, .p4 = user.ProviderUserKey})
    End If
    End Sub
    End Class
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated