0
votes

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['GroupA'].ContainsCurrentUser

But it is look like hack.

1

1 Answers

0
votes

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