My requirement in one of my projects is like, I have 2 Active Directory Groups say Team Group and HR group and members(users) total of 25. So I have to differentiate those 25 users in under which group will go. This I have to do in SharePoint 2010. Can anyone get me out of this problem?
-
It isn't clear what exactly you are trying to do. Are you trying to secure content? Can you elaborate?– Kit MenkeCommented Dec 15, 2011 at 17:37
-
actually how can we get the users list of a particular group... Actually in my project iam sending mail through workflow by sharepoint designer 2010..so if user inserts an item in custom list the mail has to go to his particular Managers group...– Naresh NemuriCommented Dec 16, 2011 at 4:20
-
If I understand correctly, you're trying to lookup the current user's manager and then get the Manager's distribution lists to send an email to?– Kit MenkeCommented Dec 16, 2011 at 14:41
-
yes,exactly..i wants to send email to manager's group..– Naresh NemuriCommented Dec 22, 2011 at 5:07
2 Answers
It sounds like you want to use the user's domain username to see if that user is a member of a specific active directory group or not. This can be easily done using a C# function such as the one posted here by Nick (.net 3.5 referencing System.DirectoryServices.AccountManagement):
public List<string> GetGroupNames(string userName)
{
var pc = new PrincipalContext(ContextType.Domain);
var src = UserPrincipal.FindByIdentity(pc, userName).GetGroups(pc);
var result = new List<string>();
src.ToList().ForEach(sr => result.Add(sr.SamAccountName));
return result;
}
You can then loop through all groups a user belongs to in order to determine if a user belongs to a specific group or not.
Pete
Active director security groups can be used in SharePoint groups. So you'd just want to add the specific AD security group to corresponding SharePoint groups. Then you can do any access and permissions you need from that point on to the SharePoint content.
-
Actually how can we get the users list of a particular group... Actually in my project iam sending mail through workflow by sharepoint designer 2010..so if user inserts an item in custom list the mail has to go to his particular Managers group... Commented Dec 16, 2011 at 4:20