以编程方式搜索特定 SharePoint 用户

发布于 2024-10-01 09:59:15 字数 284 浏览 12 评论 0原文

我有一个 InfoPath 表单,填写者需要指定人员。随后,工作流程会将任务分配给这些人。我正在寻找的是一个类似于 SharePoint 的用户字段的人员选择器,但我可以在 InfoPath 中使用它。我已经设计了一个表单来执行此操作,填充者可以在其中输入姓名或电子邮件,并且该表单将列出 site.allusers 组的结果。

问题是,如果需要添加到表单中的人员以前从未访问过此特定网站集怎么办?他们的帐户不会列在“所有用户”列表中。

我可以在对象模型中的哪个位置搜索能够通过 SharePoint 进行身份验证的用户?

I've an InfoPath form that the filler needs to specify people. A workflow later assigns tasks to these people. What I'm looking for is a people picker like what SharePoint has for user fields, but that I can use in InfoPath. I've already designed a form to do this where the filler can put in a name or email and the form will list results from the site.allusers group.

The problem is, what if the person that needs to be added into the form has never accessed this particular site collection before. Their account isn't going to be listed in the AllUsers list.

Where in the object model can I search for a user that is able to authenticate with SharePoint?

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

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

发布评论

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

评论(2

妖妓 2024-10-08 09:59:15

为什么不直接使用 InfoPath 中的 OTB 并将其配置为指向您的 SharePoint 环境呢?

http:// www.sharepointassist.com/2009/02/27/adding-a-contact-selectorpeople-picker-to-an-infopath-form/

如果您正在运行带有 AD 集成的 MOSS,那么它应该会自动检索其中的每个人如果启用了 AD 同步,则为您的域。

Why not just use the OTB one in InfoPath and configure it to point to your SharePoint environment?

http://www.sharepointassist.com/2009/02/27/adding-a-contact-selectorpeople-picker-to-an-infopath-form/

If your running MOSS with AD integration, then it should automatically retrieve everyone that's in your domain if AD synch is enabled.

心安伴我暖 2024-10-08 09:59:15

我认为这里的问题是,即使您确实找到了用户列表,如果用户信息列表中不存在该用户,工作流也不会触发任何操作。

如果用户信息列表中不存在用户,则您将无法通过 SharePoint 对象模型找到他们,因为它们不存在于 SharePoint 中。您必须通过其他方式找到它们。

因此,基本上,这取决于 SharePoint 服务器上的身份验证配置方式:

如果您使用 FBA,则可以使用 SharePoint 进行身份验证的用户必须存在于 SQL 数据库中的某个位置。 Membership.Provider将为您提供 FBA 会员资格提供商的钩子(无论是 SqlMembershipProvider 还是其他)。然后,您可以使用诸如

Membership.Provider.GetUser(username)

查看用户是否存在之类的方法。您还可以循环浏览用户或查找所有现有用户名,然后将其显示在人员选择器中。

如果您使用 Windows 身份验证,则必须在 AD 中查找潜在用户。您需要的是 DirectoryEntry 对象。我想只有某个 AD 组的用户才能访问 SharePoint?如果是这样,则将该组与 DirectoryEntry 对象隔离,循环访问用户,您将获得人员选择器的数据源。

正如我上面所说,两种方法都会为您提供可能的用户,但如果用户尚未登录,则不会使工作流程正常工作。工作流程仅适用于用户信息列表中确实存在的用户。

当有人选择 SharePoint 中不存在的用户时,您可能必须通过代码创建它。执行此操作的安全方法是使用 SPWeb.EnsureUser

检查指定的登录名是否
名称属于有效用户
网站,并且如果登录名是
尚不存在,将其添加到 Web
站点.站点。

所以真的,无处回答你的问题。您需要在它们可能来自的地方寻找它们。

I think that the problem here is that even if you do find a list of users, the workflows won't trigger any actions if the users don't exist in the User Information List.

If the users don't exist in the User Information List, then you won't be able to find them via the SharePoint object model because they don't exist in SharePoint. You will have to find them some other way.

So basically, it depends on how the authentication is configured on your SharePoint server :

If you are using FBA, then the users who can authenticate with SharePoint must exist in a SQL database somewhere. Membership.Provider will give you a hook on your FBA membership provider (whether it's a SqlMembershipProvider or something else). You can then use methods like

Membership.Provider.GetUser(username)

to see if a user exists. You can also loop through your users or find all the existing usernames which you could then display in your people picker.

If you are using windows authentication, you will have to look in your AD to find the potential users. The DirectoryEntry object is what you'll need. I imagine that only users from a certain AD group can access SharePoint? If so, then isolate that group with the DirectoryEntry object, loop through the users and you will have your data source for the people picker.

As I said above though, either method will give you the possible users, but it won't make the workflow work if the users have not logged in. Workflows will only work properly with users that do exist in the User Information List.

When someone picks a user that doesn't exist in SharePoint, you will probably have to create it via code. A safe way to do this is with the SPWeb.EnsureUser.

Checks whether the specified login
name belongs to a valid user of the
Web site, and if the login name does
not already exist, adds it to the Web
site.site.

So really, to answer your question, nowhere. You need to look for them where they could be coming from.

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