2011-01-14 62 views
4

我編寫了以下代碼來編輯MOSS 2007的用戶配置文件。用戶配置文件正在通過Active目錄進行填充。Sharepoint-活動目錄配置文件

SPSecurity.RunWithElevatedPrivileges(delegate() 
      { 
       SPSite sc = new SPSite("http://xxxxx:81"); 
       ServerContext context = ServerContext.GetContext(sc); 
       HttpContext currentContext = HttpContext.Current; 
       HttpContext.Current = null; 
       UserProfileManager profileManager = new UserProfileManager(context); 
       foreach (UserProfile profile in profileManager) 
       { 
        if (profile[PropertyConstants.PreferredName].ToString().Contains("Domain\\")) 
        { 
         profile[PropertyConstants.PreferredName].ToString().Replace("Domain\\", "").ToString(); 
         profile.Commit(); 
         NoOfUser++; 
        } 

}

細節都被正確地更新。

我的問題是我需要使用哪個站點來更新細節。

例如,我擁有SSP服務WebApplication,管理中心Web應用程序和其他Web應用程序。

我需要使用哪個站點來更新配置文件,以便在所有站點中更新配置文件名稱。

難道有人指出我在正確的方向。

謝謝。 Hari Gillala NHS Direct。

回答

3

使用sharepoint 2007,SPSite屬於SPWebApplications,它與SSP相關聯,後者存儲用戶配置文件屬性。

SPSite sc = new SPSite("http://xxxxx:81"); 
ServerContext context = ServerContext.GetContext(sc); 

這些線路有效性查找與您傳遞的SPSite URL關聯的SSP。

它看起來像你只有一個SSP,讓你在構造函數中使用任何的SPSite網址會給你一個參考正確的SSP。

將信息存儲在SSP數據庫中後,計時器作業將信息從SSP存儲複製到單個SPSite數據庫,並將其隱藏到「用戶信息列表」中。

此鏈接解釋了它的2010年,讓我看看,如果我能找到它的2007年:

http://www.harbar.net/articles/sp2010ups.aspx

編輯

我找到了2007年解釋爲你鏈接:

http://blah.winsmarts.com/2007-7-MOSS_User_Profile_Info_-_How_the_information_flows.aspx

+0

非常感謝回覆。這真的很有幫助。很好的解釋。謝謝 – 2011-01-14 11:49:23