searching for FBA users on SharePoint 2007

December 24th, 2009 | Posted by Marijn in fba | sharepoint

So, you created this big portal for your suppliers, customers or other in SharePoint. You have implemented FBA but now you want to search in this extensive list of people ?

Continuing on the FBA Codeplex solution by Stacy Draper, adding just a few lines of code can do this for you !

The FBA solution already has a Stored Procedure “Search User by Name”. You can use this (in addition you can also change this procedure to search on parts of the name).

 

Next, edit the UsersDisp.aspx file:

add in the content page the textfield and search button:

search on user name:

<form>      
<asp:textbox ID="tna" text="" runat="server"/>      
<asp:Button ID="searchbtn" OnClick="mkSarch" runat="server" text="Search"/>      
<asp:Button ID="clear" OnClick="mkEmpty" runat="server" text="Empty"/>      
</form&gt

;

Next, put some code in the script part of the page:

    protected void mkSearch(object sender, EventArgs e)
{
if (tna.Text != “”)
{
searchUser(tna.Text);
}else
{
FillGrid();
}

}

protected void mkEmpty(object sender, EventArgs e)
{
tna.Text=””;
FillGrid();
}

protected void searchUser(string searchValue)

{

MembershipUser user;
MembershipUserCollection users = new MembershipUserCollection() ;
users = Membership.FindUsersByName(searchValue);

MemberGrid.DataSource = users;
MemberGrid.DataBind();
}


Et voila, now you should have a fully functional search on your FBA management page!

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

2 Responses



Leave a Reply

%d bloggers like this: