Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 1st, 2010, 04:02 AM
Authorized User
 
Join Date: Jul 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to retreive user through its profile properties?

Hi,

I want to customize the user search on Admin's ManageUser.aspx.

And add the First Name and Last Name along with Email and Username to the drop down list.

Have anyone done this before?

Can anyone tell me how can I modify the membership module to achieve this functionality?

Regards,
dazy
 
Old February 1st, 2010, 11:34 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

What you are essentially trying to do is to query based on profile properties. Unfortunately, using the default SqlProfileProvider, this is not possible. This is because the profile data is serialized as a blob in the table, rather than in seperate columns, so you can't target specific properties in a query.

If you really need to do this, you need to use a custom profile provider that maps profile properties to a strictured database table. ScottGu has a blog post that explains how to do this here.

http://weblogs.asp.net/scottgu/archi...10/435038.aspx
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old February 1st, 2010, 12:37 PM
Authorized User
 
Join Date: Jul 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But I think I can do it by modifing the filteredUsers() function of ManageUser.aspx page.

Code:
MembershipUserCollection AllUsers = new MembershipUserCollection();
    MembershipUserCollection AllAdmins = new MembershipUserCollection();

private void GetUsersByName(String FN, String LN)
    {
       

        string[] AllAdmins = Roles.GetUsersInRole("Admin");

        
        if (FN != null)
        {
            
            foreach (MembershipUser User in AllUsers)
            {
                foreach (string Admin in AllAdmins)
                {
                    ProfileCommon profile = new ProfileCommon();
                    profile = profile.GetProfile(User.UserName);
                    if (FN == profile.FirstName)
                    
                    {
                        requiredUsers.Add(User);
                        
                    }
                }
                
            }
        
        }

       
        if (LN != null)
        {
           
            foreach (MembershipUser User in AllUsers)
            {
                foreach (string Admin in AllAdmins)
                {
                    ProfileCommon profile = new ProfileCommon();
                    profile = profile.GetProfile(User.UserName);
                    if (LN == profile.LastName)
                    {
                        requiredUsers.Add(User);
                        
                        
                    }
                }
            }
        
        
        }    
    
    }
But I guess there is some issue with the loops placement because in some conditions this code works and in others not.

What is your opinion about this solution?

Regards,
dazy.
 
Old February 1st, 2010, 12:51 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

What are you trying to do by adding an AllAdmins collection here?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old February 1st, 2010, 01:09 PM
Authorized User
 
Join Date: Jul 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm trying to retrieve all the admins on the ManageUsers.aspx page, so that I can edit or delete their accounts.

Regards,
dazy
 
Old February 1st, 2010, 01:19 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Okay, then why do you need to search by first name or last name then?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old February 1st, 2010, 01:33 PM
Authorized User
 
Join Date: Jul 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Search by First and Last Name is the requirement of my project. It is like super admin can search the admins by their First Name, Last Name.

Regards,
dazy





Similar Threads
Thread Thread Starter Forum Replies Last Post
user profile trouble Maxxim BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 7 October 9th, 2007 06:24 PM
Profile properties depending on the member type mecca BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 24th, 2007 04:43 PM
want to retreive current user name in windows al_samirr Access VBA 2 November 29th, 2006 01:46 AM
How can I retreive user role from sql server 2005? MAKO C# 0 July 7th, 2006 08:13 AM
User Profile edgelogix Pro PHP 1 December 3rd, 2005 04:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.