开发者

Add Active Directory group to a SharePoint Site programmatically?

I have developed a web part where a user can create new sites, set permission and so on in an easier and fas开发者_开发技巧ter way than have to go through the menues in SharePoint.

As it is now I populate listboxes with all the SharePoint users and groups and the user selects what permission he/she wants to give them and it's all working fine.

However, I was now asked to also populate the listboxes with users and groups from an Active Directory. I can populate a listbox with users from active directory and give them permission but not with AD groups.

When I google the problem most people say that it's possible to add a group but the users in that group, from AD, will not be able to log in (they have to be imported first). Most posts are from '07-08 though so I'm wondering if this is still the case with SharePoint 2010?

Thanks in advance.


The critical bit of code is the expansion of the group

I have always used the Contact class

using Microsoft.Office.Workflow.Utility;

public Contact[] GetGroupMembers(SPWeb web) {
 Contact c = Contact.FromName("somegroup", web);
 if (c != null) {
  Contact[] contacts = new Contact[] { c };
  bool reachedMaxCount = false;
  contacts = Contact.ExpandGroups(web, contacts, 100, out reachedMaxCount);
  return contacts;
 } else {
  return new Contact[0];
 }
}

I needed to tweak my 2007 code, by changing the namespace to the 2010 version of the workflow assembly, but that was all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜