More in this section

Forums / Developing with Sitefinity / Getting TelerikADMembershipProvider FindUsersByName to work

Getting TelerikADMembershipProvider FindUsersByName to work

2 posts, 0 answered
  1. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    19 Oct 2007
    Link to this post

    I'm using the "TelerikADMembershipProvider" Member Provider and, as a result, the "Find Username" in the Administration section doesn't work.

    To get this to work I had to override the "FindUsersByName" method and replace the "%" with "*" in the UserName string.  Here is the code:

    using System;  
    using System.Collections.Generic;  
    using System.Text;  
    using System.Text.RegularExpressions;  
    using System.Web;  
    using System.Web.Security;  
     
    namespace Security  
    {  
        class CustomMemberProvider : Telerik.Security.ActiveDirectory.TelerikADMembershipProvider  
        {  
     
            public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)  
            {  
                string newUsername = Regex.Replace(usernameToMatch, @"\%", "*");  
     
                return base.FindUsersByName(newUsername, pageIndex, pageSize, out totalRecords);  
            }  
        }  
    }  
     

    I'm not sure why this is needed.  But the code above seems to work and make the Active Directory username search working.

    Gabe
    ==============
  2. Yasen
    Yasen avatar
    121 posts
    Registered:
    18 May 2013
    22 Oct 2007
    Link to this post
    Hello Gabe,

    Thanks for the feedback. We are aware of this issue -  it is also valid for the search-by-letter functionality.

    In queries against an Active Directory data source the wildcard ( * ) is equal to the wildcard ( % ) in sql syntax. 

    For example, if you search for "john" with an sql provider your query is similar to: SELECT ... WHERE username LIKE %john% ... and if you use an active directory provider your query should be similar to: ... (sAMAccountName=*john*) ... 

    This bug is already fixed the changes will be available with the service pack.

    Kind regards,
    Yasen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered