以编程方式在 SharePoint 中查找用户
我遇到过一种情况,我需要能够通过用户的活动目录名称查找用户。我尝试在 SPSite.Users、SPSite.AllUsers 和 SPSite.SiteUsers 属性中查找用户,但不保证该用户位于任何这些列表中。对于通过已授予站点权限的 Active Directory 组获得站点权限的用户,各个用户列表中不会列出该用户,只有 Active Directory 组的记录。有没有一种方法可以在 SharePoint 中以编程方式查找用户,而无需直接通过 LDAP 查询活动目录?
我理想地希望找到一种适用于基于表单的身份验证和 AD 身份验证的机制,但我需要找到一种适用于 AD 身份验证的机制。
I’ve encountered a situation where I need to be able to lookup a user by their active directory name. I’ve tried looking for the user in the SPSite.Users, SPSite.AllUsers and SPSite.SiteUsers properties, but the user isn’t guaranteed to be in any of those lists. For users who gain permission to the site via an active directory group that has been granted permission to the site, there is no listing for the user in the various user lists, only a record for the active directory group. Is there a way to find a user programmatically in SharePoint without directly having to query active directory via LDAP?
I would ideally like to find a mechanism that works for both forms based authentication and AD authentication, but I need to find a mechanism that works with AD authentication.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 SPWeb.EnsureUser:
此方法适用于 AD 和 FBA。如果您同时使用两者,则需要在非默认提供商的用户名前添加如下前缀:
Try SPWeb.EnsureUser:
This method works with both AD and FBA. If you are using both, you will need to prefix the username from a non-default provider with something like this: