0
votes

How do we get the users from an Active directory group inside a SharePoint group. In my project i need to send emails to all the members in a a SharePoint group, and the SharePoint group contains Users as well as a security group in Active directory. So how do i loop through all these??

i tried SPFieldUserValueCollection to get all the groups and users and checking whether each item is a group or user but its not working?? Can any one help me with this???

Thanks in Advance....

2

2 Answers

2
votes

To check whether the user is an SPUser or domain group you can use below property:

SPUser.IsDomainGroup

This link details about how to fetch the user details by looping through the AD Group. http://christopherclementen.wordpress.com/2012/08/13/get-all-users-from-sharepoint-group-including-active-directory-group-v2/

1
votes

You can use SPUtility.GetPrincipalsInGroup method to do that. input parameter is a NT account name of the security group.