Solved

Custom MembershpUser

Posted on 2007-11-13
5
376 Views
Last Modified: 2008-02-01
I have created a custom MembershipUser class..

Public Class CustomMembershipUser
    Inherits MembershipUser

How do I define this in my web.config file?

thanks!
0
Comment
Question by:Starr Duskk
  • 3
5 Comments
 
LVL 16

Accepted Solution

by:
anoyes earned 500 total points
ID: 20276709
You don't have to do anything to web.config to get your custom MembershipUser class to work.  You do, however, have to modify the MembershipProvider.  If you don't already have a custom MembershipProvider, you have to start there.  If you do, take a look at this article from MS regarding implementing custom MembershipUsers: http://msdn2.microsoft.com/en-us/library/ms366730.aspx

If you need to do a custom MembershipProvider, there are a ton of tutorials out there, but here's one that I used when I started implementing my custom MP: http://www.devx.com/asp/Article/29256/0/page/
0
 
LVL 27

Expert Comment

by:Sammy
ID: 20277715
actually you have to set your Custom provider as the default provider for the application
   
<membership defaultProvider="CustomMembershipUser" >
      <providers>
     <clear />
        <add name="CustomMembershipUser"
          type="CustomMembershipUser" />
      </providers>
    </membership>
0
 
LVL 16

Expert Comment

by:anoyes
ID: 20277761
Right, but he hasn't created a membership provider, he's only created a membership user.  I probably should have been more specific - you don't have to do anything to web.config assuming you've already got your provider configured properly.  I don't believe you can set a MembershipUser class as a membership provider...
0
 
LVL 1

Author Comment

by:Starr Duskk
ID: 20280931
Yes, I have the custom provider in the web.config, I just want to clarify some things after looking at that example.

In the link you gave me, the GetUser references the MembershipUser...

Public Overrides Function GetUser(ByVal username As String, _
                                  ByVal userIsOnline As Boolean) As MembershipUser

Then it knows my custom user exists, because I name it here, but I don't inherit, import or implement it in anyway?

Dim u As OdbcMembershipUser = Nothing

which I'm assuming that means it now says, there is my class, set this "u" as my custom class.

Then in the example, the GetUser method it calls:

u = GetUserFromReader(reader)

And in the GetUserFromReader it does this....

            Dim u As MembershipUser = New MembershipUser(Me.Name, _
                                                  username, _
                                                  providerUserKey, _
                                                  email, _
                                                  passwordQuestion, _
                                                  comment, _
                                                  isApproved, _
                                                  isLockedOut, _
                                                  creationDate, _
                                                  lastLoginDate, _
                                                  lastActivityDate, _
                                                  lastPasswordChangedDate, _
                                                  lastLockedOutDate)


If I refer back to the custom user code... there is a:

Public Sub New(ByVal providername As String,

but I have also seen it written in other examples as....

Public Sub New(ByVal membershipProvider As MembershipProvider,...

which should it be... String or MembershipProvider?

Okay, those things should probably clarify it for me.

thanks!



0
 
LVL 16

Expert Comment

by:anoyes
ID: 20282827
I'm not sure I entirely understand your questions, but...The only place you have to do inheriting is in the actual class for the custom user, like you showed in your initial post.  Get user, when it returns u, is just returning your custom user as an object.  ProviderName as String should be fine.  If I haven't answered your questions could you please clarify?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now