Home > SharePoint 2010 > SharePoint 2010 FBA: Enable search by part or full name in People Picker

SharePoint 2010 FBA: Enable search by part or full name in People Picker


 
Please refer to this post of mine on how to configure Forms Based Authentication (FBA) on a SharePoint Web Application using ASP.NET SQL Membership Provider.

After you setup FBA the People Picker control by default will only search for user’s by using the username. However, if you would like to search for users by part or full display name then you will need to carry out the following changes to the Membership Database:

  • Add a column “ProfileNames” of type nvarchar(255) in the table: aspnet_Users
  • Update the stored procedure: aspnet_Membership_FindUsersByName by replacing the following where clause:
    WHERE  u.ApplicationId = @ApplicationId AND m.UserId = u.UserId AND u.LoweredUserName LIKE LOWER(@UserNameToMatch) 
    

    with:
     

    WHERE  u.ApplicationId = @ApplicationId AND m.UserId = u.UserId AND u.ProfileNames LIKE '%' + LOWER(@UserNameToMatch) + '%'
    
  • Create the following Trigger on the “aspnet_Profile” table:
    CREATE TRIGGER [dbo].[ProfileProperty_Trigger] 
       ON   [dbo].[aspnet_Profile] 
       AFTER INSERT,UPDATE
    AS 
    BEGIN
    SET NOCOUNT ON;
    DECLARE @Names nvarchar(50)
    DECLARE @UID nvarchar(50)
    
    SELECT 
    @Names = p.PropertyValuesString,
    @UID = p.UserId
    FROM aspnet_Profile p
    INNER JOIN inserted i
    ON p.UserId = i.UserId
    
    UPDATE aspnet_Users SET ProfileNames = @Names WHERE aspnet_Users.UserId = @UID
    END
    
    •  
      That is it, after making these changes the People Picker control should now match by username as well as display name.

      Advertisements
  1. March 17, 2014 at 4:52 am

    My spouse and I stumbled over here by a different page and thought I should check things out.
    I like what I see so i am just following you.
    Look forward to looking over your web page repeatedly.

  2. May 4, 2014 at 9:04 am

    Hi, I do think this is a great blog. I stumbledupon it 😉 I may return
    yet again since i have book-marked it. Money and freedom is the
    greatest way to change, may you be rich and continue to
    guide other people.

  3. February 25, 2016 at 7:39 pm

    Sorry, can u help with 2013 SP?

  4. berna sara
    August 26, 2016 at 3:10 am

    Nice article ! Apropos , if your business has been looking for a IRS W-3 , We discovered a template version here http://goo.gl/hBmtAu.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: