I need to retrieve all SPUser
's from a SPGroup
. Unfortunately, the group may contain Active Directory groups, so a simple SPGroup.Users
is not enough (I'd just get a single SPUser
for the AD group, with the IsDomainGroup
property set to true).
Does anyone have a good idea how can I obtain a list of all SPUser
's, descending into any Active Directory groups contained in a SPGroup
? Is there an alternative to SPGroup.ContainsCurrentUser
that takes a SPUser
parameter?
Based on a blog post I found, I have written the following code:
I don't like the fact that I have to impersonate every single user, and this code will only find AD users that have already been imported into SharePoint (so an
SPUser
exists for them), but that's good enough for me.