Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old December 4th, 2006, 03:20 PM
saf saf is offline
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you so much. Works like a charm. Only thing I am trying to do now is only select certain usernames. I put a usertype field in the aspnetdb users table and want to select only usernames that have this value set. Am I going in the right direction? I assume I need some sort of custom paramerter for the getallusers method.
Your help is GREATLY appreciated.



Reply With Quote
  #12 (permalink)  
Old December 4th, 2006, 03:46 PM
Imar's Avatar
Wrox Author
Points: 67,271, Level: 100
Points: 67,271, Level: 100 Points: 67,271, Level: 100 Points: 67,271, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,227
Thanks: 66
Thanked 1,413 Times in 1,393 Posts
Default

Unfortunately, that is not supported out of the box.

One easy way to do this is to put those users in a specific group and then change the call to Membership.GetAllUsers()

to

Roles.GetUsersInRole(roleName)

That gives you a list of the users in the specified role.

Otherwise, you need to create a custom method that returns a MembershipCollection. Inside this method you could fire a custom stored procedure that returns the users based on your criteria. You can take a look at the standard stored procedures and at the code for the standard SQL providers for some ideas on how to do this.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #13 (permalink)  
Old December 5th, 2006, 01:49 PM
saf saf is offline
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One last time for a newbie....

I do have all my users that I want to display in a Role (rolename ="Members"), just need a bit more explanation on how to configure the objectdatasource to show all users in role Members...

I changes ODS TypeName to System.Web.Security.Roles, the SelectMethod to GetUsersInRole(StringRolename,returns String[]) and set parameters as follows
<asp:Parameter DefaultValue="Members" Name="roleName" Type="String" />

Am I completely off track...

Once again, thanks in advance for all your help
{

Reply With Quote
  #14 (permalink)  
Old December 5th, 2006, 05:35 PM
Imar's Avatar
Wrox Author
Points: 67,271, Level: 100
Points: 67,271, Level: 100 Points: 67,271, Level: 100 Points: 67,271, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,227
Thanks: 66
Thanked 1,413 Times in 1,393 Posts
Default

Close, but no cigar.... ;)

Here's what you should do:
Code:
<asp:ObjectDataSource ID="ObjectDataSource1" 
       runat="server" SelectMethod="GetUsersInRole" 
       TypeName="System.Web.Security.Roles">
  <SelectParameters>
    <asp:Parameter DefaultValue="Members" Name="roleName" /> 
  </SelectParameters>
</asp:ObjectDataSource>
Since GetUsersInRole() returns an array of Strings, you don't need to specify the DataValueField and DataKeyField in the dropdown:
Code:
<asp:DropDownList ID="DropDownList1" runat="server" 
        DataSourceID="ObjectDataSource1">
</asp:DropDownList>
Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #15 (permalink)  
Old December 5th, 2006, 06:07 PM
saf saf is offline
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You make it seem so easy. Thank you - Thank You - Thank You!
You save me hours of frustration....
saf

Reply With Quote
  #16 (permalink)  
Old December 6th, 2006, 07:30 AM
Imar's Avatar
Wrox Author
Points: 67,271, Level: 100
Points: 67,271, Level: 100 Points: 67,271, Level: 100 Points: 67,271, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,227
Thanks: 66
Thanked 1,413 Times in 1,393 Posts
Default

You're welcome. Glad I could help.

In case anyone else is interested in the full solution, I wrote a short article about it here: http://Imar.Spaanjaars.Com/QuickDocId.aspx?quickdoc=409

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Ivo by Cocteau Twins (Track 1 from the album: Treasure) What's This?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
User Accounts ASPNET.mdf pschulz ASP.NET 2.0 Basics 3 June 19th, 2008 12:41 PM
Users with accounts PankajGarg10 General .NET 0 April 13th, 2007 01:06 AM
Blocking user accounts Ben Horne Forum and Wrox.com Feedback 10 April 29th, 2004 10:19 PM
Accounts RM82 BOOK: ASP.NET Website Programming Problem-Design-Solution 2 April 7th, 2004 09:37 PM
Enums for accounts??? rcarter BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 7th, 2003 11:07 PM



All times are GMT -4. The time now is 12:50 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.