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
精彩评论