如何获取用户属于sharepoint中的哪个组?
我的网站集中有 350 个组。我需要通过传递登录名来查找用户并获取他所属的组?如何以编程方式获取?
I have 350 groups in in my sites collection. I need to find a user by passing login name get his groups belongs to? How to get programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SPUser
by login name (alternatively use SPWeb.EnsureUser if you don't know if they have been added yet)在 ASP.NET 论坛上查看这篇精彩的文章:
C# 示例:如何获取所有组、用户和使用 SPGroup、SPUser、SPRole ...的 SharePoint 角色...
Checkout this excellent post on ASP.NET forums:
C# Example: How to get all groups, users and roles from SharePoint using SPGroup, SPUser, SPRole ...
检查这个
SPFieldUserValue usersField = new SPFieldUserValue(SPContext.Current.Web);
bool isUser = SPUtility.IsLoginValid(SPContext.Current.Site, usersField.User.LoginName);
SPGroup 组 = SPContext.Current.Web.Groups.GetByID(usersField.LookupId);
CheckOut this one
SPFieldUserValue usersField = new SPFieldUserValue(SPContext.Current.Web);
bool isUser = SPUtility.IsLoginValid(SPContext.Current.Site, usersField.User.LoginName);
SPGroup group = SPContext.Current.Web.Groups.GetByID(usersField.LookupId);