开发者

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

开发者 https://www.devze.com 2023-01-29 12:07 出处:网络
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.

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

精彩评论

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