0

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.

Sergey Azarkevich
  • 2,641
  • 2
  • 22
  • 38

1 Answers1

0

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

Christian
  • 3,503
  • 1
  • 26
  • 47