FindUsersByName 是否应该包含部分匹配项?

发布于 2024-08-05 09:20:45 字数 422 浏览 0 评论 0原文

MSDN 文档在这一点上并不准确。

它在一个地方说:“获取会员用户的集合,其中用户名包含要匹配的指定用户名。”

后来它说,“FindUsersByName 返回成员资格用户列表,其中用户名匹配为配置的 applicationName 提供的 usernameToMatch。”

SQLMembershipProvider 支持通配符,但文档没有说明我是否也必须对自定义成员资格提供程序执行此操作。

编辑:我实际上更多地询问会员提供商的意图,而不是我在具体情况下应该做什么。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

落在眉间の轻吻 2024-08-12 09:20:45

FindUsersByName 函数将对您传入的字符串进行匹配。

如果您希望它进行部分匹配,则需要在您要搜索的字符串末尾添加“%”。

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.

走过海棠暮 2024-08-12 09:20:45

文档中的这句话对此进行了解释:

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

“获取成员资格用户的集合,其中用户名包含要匹配的指定用户名。”

是准确的句子,如果您搜索“DAV*”,您应该得到“Dave”、“David”、“Davis”等。

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.

瑶笙 2024-08-12 09:20:45

让我们对其进行更严格的限制(查找完全匹配),以确保用户“joe”无法访问用户“joel”的数据:)

无论如何,您真的需要查找仅提供部分名称的用户吗?

编辑:
现在再次检查您链接到的 MSDN 方法,它的名称是 FindUsersByName (用户,而不是用户),因此该方法能够返回多个用户。在这种情况下,我假设您应该实现代码以返回所有匹配项。
如果方法是FindUserByName,那么它是相反的答案(您有方法GetUser

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文