开发者

How to get user belongs to which group in sharepoint?

I have 350 groups in in my sites collection. I need to find a user by passing login name ge开发者_Python百科t his groups belongs to? How to get programmatically?


  1. Use SPWeb.AllUsers collection to get the SPUser by login name (alternatively use SPWeb.EnsureUser if you don't know if they have been added yet)
  2. Use SPUser.Groups to get the groups the user is a member of


Checkout this excellent post on ASP.NET forums:

C# Example: How to get all groups, users and roles from SharePoint using SPGroup, SPUser, SPRole ...


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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜