Context
I have a List<SPPrincipal> that is a mix of SPGroup, SPUser and AD Users.
Problem
I'm trying to find out how to determine if an SPPrincipal I have is an SPUser, SPGroup or an AD user.
Attempted solutions
Ive tried something like:
foreach (var principal in listOfPrincipals
{
if (principal is SPGroup) { /* do stuff */ }
}
But this does not appear to work.
Does anyone have any ideas about how to resolve this information ?
Update
After fiddling a bit I came to this solution that seems to work for SPGroup and SPUser
foreach (SPPrincipal subscriber in listOfSubscriberUsersAndGroups)
{
var isGroup = subscriber is SPGroup;
var isUser = subscriber is SPUser;
}
Here an SPGroup is found correctly, and SPUser is found correctly.
Update 2
The above actually works like it is supposed to. My mistake was that the SPPrincipal I was testing was actually a Domain-group, and not an SPGroup (red ears)