コード例 #1
0
ファイル: SPCommon.cs プロジェクト: kenstammjr/SPA
        public static string GetUserProfilePictureURL(string UserName)
        {
            string             url            = string.Empty;
            SPServiceContext   serviceContext = SPServiceContext.GetContext(SPContext.Current.Site);
            UserProfileManager upm            = new UserProfileManager(serviceContext);

            if (upm.UserExists(UserName))
            {
                Microsoft.Office.Server.UserProfiles.UserProfile profile = upm.GetUserProfile(UserName);
                if (profile != null)
                {
                    url = profile["PictureURL"].Value.ToString().Replace("MThumb", "LThumb");
                    //Action.Write(profile.ID.ToString(), UserName);
                    //Action.Write(profile.PersonalUrl.ToString().ToString(), UserName);
                    //Action.Write(profile.PersonalUrl.ToString().ToString(), UserName);
                    //Action.Write(profile.PublicUrl.ToString().ToString(), UserName);
                    //Action.Write(profile.RecordId.ToString().ToString(), UserName);
                    //Action.Write(profile.DisplayName.ToString().ToString(), UserName);
                }
                else
                {
                    //Action.Write("profile is null", UserName);
                }
            }
            // change to default if user does not have an image specified
            if (string.IsNullOrEmpty(url))
            {
                url = "/_layouts/15/images/spa/PHOTO-NOT-AVAILABLE.png";
            }
            return(url);
        }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {

        using (SPSite site = SPContext.Current.Site)
        {
            SPServiceContext context =
                SPServiceContext.GetContext(site);
            upm = new UserProfileManager(context);
            up = upm.GetUserProfile("abcph\\administrator");
            Response.Write("work email is " + up[PropertyConstants.WorkEmail].Value + "<br>");
            Response.Write("state is " + up["State"].Value);

        }
    }