开发者

Sharepoint: How to determine if user is member of group through API

I need know if some(not only current) user is member of some group.

Moreover, I need know if user placed inside domain group, which placed in sharepoint group. For example:

Group 'GroupA' contains user 'XXX\Domain Users'. I have user 'XXX\someuser' from domain XXX and need to know if this is member of 'GroupA'. In this example it is true.

For now I found only one way:

Impersonate as specified user and check web.SiteGroups['G开发者_如何学CroupA'].ContainsCurrentUser

But it is look like hack.


Should be the same as in .NET:

principal.IsInRole('GROUPNAME')

Or you can try to do following:

WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
if( principal.IsInRole(@"MYCOMPANY\AllFTE") ){
  // perform operation allowed for fulltime employees
}

Maybe that post helps you out: http://mnigbor.blogspot.com/2010/05/using-windowsidentityimpersonate-in.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜