views:

84

answers:

3

The MSDN documentation isn't precise on this point.

It says in one place: "Gets a collection of membership users where the user name contains the specified user name to match."

Later it says, "FindUsersByName returns a list of membership users where the user name matches the supplied usernameToMatch for the configured applicationName."

The SQLMembershipProvider supports wildcards, but the documentation doesn't say whether I must also do so with my custom membership provider.

Edit: I'm really asking more about the intent of the Membership Provider rather than what I should do in my specific situation.

A: 

Let's make it more restrictive (find exact match) to be sure that user 'joe' has no access to data of the user 'joel' :)

Anyway, do you really need to find a user given only part of it's name?

EDIT: Now checked again the MSDN method you linked to, and it's name is FindUsersByName (users, not user) so the method is able to return more than one user. It this case I assume you should implement the code to return all matches. If the method would be FindUserByName, then it is the opposite answer (you have the method GetUser for this)

twk
In an admin site, that's a common need.
David Stratton
As an admin I am still not convinced. Admin tasks are not so frequent in this matter, different methods can be applied.The true answer should be: depends of your need :)
twk
A: 

This sentence in the documentation explains it:

The SqlMembershipProvider performs its search using a LIKE clause against the usernameToMatch parameter. Any wildcards that are supported by SQL Server in LIKE clauses can be used in the usernameToMatch parameter value.

SO

"Gets a collection of membership users where the user name contains the specified user name to match."

is the accurate sentence if you do a search for "DAV*" you should get "Dave", "David, "Davis", etc.

David Stratton
I understand that's how SqlMembershipProvider does it, but does this imply that all other implementations should support this? Furthermore, am I expected to support LIKE wildcards?
Larsenal
A: 

The FindUsersByName function will do a match on the string you pass in.

If you want it to do a partial match then you need to add '%' on the end of the string you're searching for.

Mike Mengell