SharePoint2010创建MySite

来源:互联网 发布:网络安全法实施方案 编辑:程序博客网 时间:2024/06/05 06:16
        using (SPSite site = new SPSite(siteUrl))            {                if (!site.RootWeb.Exists)                {                    throw new FileNotFoundException();                }                SPServiceContext serviceContext = SPServiceContext.GetContext(site);                UserProfileManager profileManager = new UserProfileManager(serviceContext);                UserProfile profile = null;                if (profileManager.UserExists(MySiteOwner))                {                    profile = profileManager.GetUserProfile(MySiteOwner);                }                else                {                    profile = profileManager.CreateUserProfile(MySiteOwner);                }                profile.CreatePersonalSite();            }