在sharepoint中按组获取用户
谁能告诉我如何使用 sharepoint 获取某个组内的用户?
所以我有一个包含用户和/或组的列表。 我想检索该列表中的所有用户。 有没有办法区分列表项是组还是用户。 如果它是一个组,我需要获取该组内的所有用户。
我使用 C#,并且尝试通过使其成为控制台应用程序来做到这一点。
我是 Sharepoint 的新手,我真的跳入了泳池的最深处,任何帮助将不胜感激。
干杯..
can anyone show me how to get the users within a certain group using sharepoint?
so i have a list that contains users and or groups. i want to retrieve all users in that list. is there a way to differentiate between whether the list item is a group or user. if its a group, i need to get all the users within that group.
im using c#, and im trying to do thins by making it a console application.
im new to sharepoint and im really jumping into the deep end of the pool here, any help would be highly appreciated.
cheers..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要知道的第一件事是,当您有一个包含“用户/组”字段的列表时,您必须了解其类型。 当项目值中有一个用户或组时,字段类型为 SPFieldUserValue。 但是,如果字段有多个用户/组选择,则字段类型为 SPFieldUserValueCollection。
我假设您的字段允许选择单个用户/组,并且您已经拥有以下对象:
现在,我们将检查用户/组的字段值并检索用户列表,无论其类型如何(该字段的名称是“Users”)。
我希望它对你有帮助。
谢谢,
佩德罗·何塞·巴蒂斯塔
The first thing you need to know is that when you have a list with a User / Group field you must be aware of its type. When you have one user or group within the item value, the field type is SPFieldUserValue. However, if the field has multiple user / group selection the field type is SPFieldUserValueCollection.
I'll assume that your field allows a single user / group selection and you already has the following objects:
Now, we'll check the field value for a user / group and retrieve a list of users, independant of which kind it is (the field's name is "Users").
I hope it helps you.
Tks,
Pedro José Batista
注意:SPUser 对象也可以是 AD 组(也就是说,“DOMAIN\Domain Users”可能存在 SPUser 对象...这就是为什么 SPUser 对象还包含属性 IsDomainGroup。
从这些信息中,您可以开始使用 SPPrincipalInfo 对象遍历 AD 组...但是,值得记住的
一件事是 SPGroup 对象包含可以遍历 AD 组的 ContainsCurrentUser 属性...这假设您有一个 SPGroup 对象。然而,
享受工作。
-斯科特
note: an SPUser object can also be an AD Group (that is to say, an SPUser object might exist for "DOMAIN\Domain Users"... which is why the SPUser object also contains the property IsDomainGroup.
From this information you can start to traverse through AD groups using the SPPrincipalInfo objects... however it's not always pleasant.
One thing worth keeping in mind is that the SPGroup object includes the ContainsCurrentUser property which can traverse AD groups... this assumes you've got an SPGroup object to work from, however.
Enjoy.
-Scott
最好使用
web.SiteGroups
而不是web.Groups
,因为组可能会被该网站继承。This is better to use
web.SiteGroups
instead ofweb.Groups
as a group might be inherited by that site.