2011-03-30 117 views
2

嗨 我使用多個站點開發應用程序,每個站點都有自己的Extranet,而且這些工作都非常精美,使用Sitecore 6.4。Sitecore外聯網管理員?

現在我需要每個站點的編輯(而不是管理員)能夠創建只能訪問連接到站點的外部網的外部網用戶,這甚至有可能嗎?

基本上我尋找的結構是這樣的:

Sitecore的\編輯器(本地外網管理員)

外網\用戶

+0

你是什麼意思,每個人都有「自己的外聯網」?如同一個外聯網站點,或只是一組外聯網用戶? – 2011-03-30 13:35:37

+0

他們有他們自己的外部網站 – 2011-03-31 07:05:04

回答

0

我想你可以把外聯網作用,爲你們每一個人「外聯網」,例如。 Site1Admin。

然後創建一個頁面,使他們能夠創建一個用戶,爲該用戶提供所需的基本角色。

這是Sitecore的6.0代碼,但它應該是相同的6.4 AFAIK:

Sitecore.Security.Accounts.User user; 
if (!Sitecore.Context.IsLoggedIn) 
{ 
    string domainUser = Sitecore.Context.Domain.GetFullName("youruser"); 
    string txtPassword = "yourpass"; 
    string txtEmail = "youremail"; 

    if (Sitecore.Security.Accounts.User.Exists(domainUser)) 
     return; 

    MembershipCreateStatus status; 
    Membership.CreateUser(domainUser, txtPassword, txtEmail, "Never?", "Always!", true, out status); 

    if (!status.Equals(MembershipCreateStatus.Success)) 
    { 
     throw new MembershipCreateUserException(status.ToString()); 
    }  
    user = //something to load the user, probably in Sitecore.Security.Accounts.User 
} 
    var role = "extranet\\Site1User"; 

    var roles = Roles.GetRolesForUser(); //this is probably only for the current context user 
    if (!roles.Contains(role)) 
    { 
     try 
     { 
      Roles.AddUsersToRole(new string[] { "youruser" }, role); 
     } 
     catch(System.Configuration.Provider.ProviderException) 
     { 
      // do nothing, just move on 
     } 

    } 
} 

這是有點簡單,是基於一些代碼,我試圖從一些工作代碼放在一起下鍋,創建一個用戶並登錄他並且應該根據你正在做的事情進行調整,因爲可能存在一些錯誤。

+0

我有點希望避免這種情況,也許認爲它可以用std來完成。功能,但我會給這個鏡頭。 – 2011-03-31 07:09:17

+0

我只想讓Sitecore用戶在管理員或「Sitecore \ Sitecore客戶帳戶管理」角色中進行檢查。 對於外聯網用戶,我假設您必須製作一些自定義代碼,以允許Extranet用戶創建其他用戶。 或者你可以試着問問Sitecore https://support.sitecore.net/helpdesk/Default.aspx – Holger 2011-03-31 07:17:59

+0

是的,它似乎工作我要去用它。 – 2011-03-31 08:11:22