views:

170

answers:

1

Hi i am using vb.net and the .net membership provider.

i want to bring back a gridview with user account information, like GetAllUsers() does. However i want to only bring back users with certain profile information, that will be users whos profile information matches the selected value in a dropdownlist on the same page. I am using profile provider to record just one extra piece of user information.

Can i change or override the GetAllUsers method for this? Adding an extra parameter so its GetAllUsers by Profile. Membership has a FindUsersByName method, i want to do something similar with users by Profile.

I am very much a noob with .net programming so i hope i have explained this ok.

A: 

Create a new membership provider class that inherits from System.Web.Security.MembershipProvider

This will give you a GetAllUsers method to override.

Add a membership section to web.config to reference your new membership provider.

<membership defaultProvider="MyMembershipProvider">
    <providers>
        <add name="MyMembershipProvider" type="MyNamespace.MyMembershipProvider"/>
    </providers>
</membership>

That's it.

However, I would add a new method instead, along the following lines:

GetUsersByCriteria(criteria as String)
Moose Factory
Thanks Moose Factory. Think im maybe getting out of my depth here. I can create the provider class but still not sure how to use GetAllUsers with the extra parameter for matching the profile information
Tones
OK, I think I misunderstood your question. Actually, I'm sure I did. Are you trying to interrogate all of the profiles held by the profile provider and return just those that have a certain value in one of the profile properties?
Moose Factory
Yes Moose thats pretty much it, although i want my return to include the other profile information. I only have one extra field in the profile provider (called district). I only want to return accounts and profiles which match the profile information selected from a dropdownlist.
Tones