我想編寫一個C#應用程序來克隆SharePoint MOSS2007角色組(及其權限),但是沒有起點。克隆sharepoint角色組
MOSS2007似乎相當欠缺記錄(在開發方面),儘管使用相當廣泛的Google搜索,仍然不知道要開始嘗試什麼。我希望這裏有人做了類似的事情,並且/或者知道SharePoint庫足以提供一個很好的參考點。
我誠摯地爲基本問題道歉,也不提供更多信息 - 如果我還有其他事情,我會!
我想編寫一個C#應用程序來克隆SharePoint MOSS2007角色組(及其權限),但是沒有起點。克隆sharepoint角色組
MOSS2007似乎相當欠缺記錄(在開發方面),儘管使用相當廣泛的Google搜索,仍然不知道要開始嘗試什麼。我希望這裏有人做了類似的事情,並且/或者知道SharePoint庫足以提供一個很好的參考點。
我誠摯地爲基本問題道歉,也不提供更多信息 - 如果我還有其他事情,我會!
'克隆'SharePoint安全組首先不是關於組本身,而是關於權限。
這些權限作爲角色分配存儲到SPWeb對象。首先,你必須找到你想要做克隆組:
SPGroup group = spWeb.Groups["name group"];
那麼你必須使用這個檢索組得到SPWeb對象上roleassignments。
SPRoleAssignment ass = spWeb.RoleAssignments.GetAssignmentByPrincipal(group2);
然後,你必須簡單地創建一個新的SPGroup和組添加到roleassignment和roleassignment到Web對象:
spWeb.SiteGroups.Add(groupName, user, user, groupDescription);
SPGroup newGroup = spWeb.SiteGroups[groupName];
SPRoleAssignment roleAssignment = new SPRoleAssignment(newGroup);
//add role to web
spWeb.RoleAssignments.Add(roleAssignment);
spWeb.Update();
在這之後,你應該有一個新的組相同的權限原來的組。
如果您沒有在SharePoint特性中執行上述操作,或者您可以通過控制檯應用程序執行上述操作。只要創建在VS一個控制檯應用程序,像這樣的東西填滿它:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
using (SPSite spSite = new SPSite("http://yoururl"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
//perform the code to clone the group here
}
}
}
}
}
當你要編輯,更改或添加組遠程你的確可以使用web服務。 webservice你需要它usergroup.asmx。您只需在SharePoint中調用它即可找到此webservice的方法。
所以瀏覽:http://MySharePointSite/_vti_bin/usergroup.asmx
這會給你的服務的所有可用方法的列表。連接到從應用程序的Web服務可以這樣做:
http://msdn.microsoft.com/en-us/library/ms458094.aspx
,這告訴你如何與用戶組Web服務交互:
將其導入到新的角色分配中。非常感謝! – Codingo
這是如何驗證?我假設你只是在ISS服務器上運行它? – Codingo
你打算如何處理羣組對象?以上示例僅介紹如何克隆組,而不是如何訪問SharePoint。您可以簡單地創建一個訪問您的SharePoint點擊環境的控制檯應用程序。 – Tjassens
對不起,看來我已經遠遠超出了我的深度。我應該閱讀什麼來了解如何做到這一點? – Codingo