Figuring out how to use a custom membership provider.

H

Harlan Messinger

My web application handles membership in different organizations. Based
on the means by which a user has reached the login screen, the
application has already determined which organization membership should
be checked against:

Session["organizationId"] = 4; //for example

Data on members is stored in a table called Participant

CREATE TABLE Participant (
...
organizationId int NOT NULL
...
)

I've created a custom membership provider:

public class PublicMembershipProvider : SqlMembershipProvider
{
...
public int OrganizationId { get; set; }
...
};

Suppose that, fully qualified, its name is A.B.C.PublicMembershipProvider.

I want to use this provider with the login control, the Create User
wizard, the password change control, etc.

So, how does this work? In web.config, do I define a membership provider
with

name="MyMembershipProvider"
type="A.B.C.PublicMembershipProvider"?

Do I set the MembershipProvider property for the various controls to
MyMembershipProvider?

In the Page_Load for the page containing one of these controls, do I set
the organization ID for the provider thus:

LoginForm1.MembershipProvider.OrganizationId = Session["organization"];

? After this, I assume that the value of the OrganizationId property
will be available for me to use in my implementation of the base class's
methods.

Am I on the right track?
 
H

Harlan Messinger

[Sorry, I meant to post this to
microsoft.public.dotnet.framework.aspnet. Follow-ups set.]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top