I need to map AD's "Member Of" property in sharepoint 2010 user profile properties. I found a guide on how to do that, How to map a user’s Active Directory group membership to their SharePoint profile but unfortunately it refers to sharepoint 2007, and to be honest I was hoping that meanwhile there was some faster/easier way to do that.
2 Answers
If you don't like the idea of running the scheduled powershell, you can resort to a WebPart in the profile (person.aspx) page.
But beware that doing direct queries to AD can bite you back for it was not built to be queried extensively (there is a good reason SharePoint synchronizes and makes a local copy of the domain), but your use case may fit in it.
That said, your web part just needs to run this DirectoryServices query:
public List<string> GetMemberships(string username) { var empty = new List<string>(); var domain = new PrincipalContext(ContextType.Domain); var user = UserPrincipal.FindByIdentity(domain, username); if(user == null) return empty; //empty result or throw ex return user.GetAuthorizationGroups().OfType<GroupPrincipal>().Select(g => g.DistinguisedName).ToList(); } I'm not sure about that, I did this in 2007 last week, and it was easy in the corresponding User Profile Synchronization Service in the dialogue for mapping AD properties to SharePoint... I guess it hasn't changed much in 2010, but if there's a simpler way, I'm happy to know too :)
- In the end I decided it would be easier and faster to just retrieve the group members through an LDAP query to the AD. Of course doing it, being the first time I try, is a whole different matter but still better then wasting time trying something of which I have even less info and examples to look to.iris– iris2012-08-06 14:57:02 +00:00Commented Aug 6, 2012 at 14:57
- How did you do that? I also want to add new Userprofile property, which sync with the field "Memeber Of" in AD.user11569– user115692012-10-24 10:53:38 +00:00Commented Oct 24, 2012 at 10:53