Solved

Custom MembershpUser

Posted on 2007-11-13
5
375 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:BobCSD
  • 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:BobCSD
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

11 Experts available now in Live!

Get 1:1 Help Now