Get UserProfile programmatically using SharePoint Server Object Model?



                using (SPSite site = new SPSite("Your site url here"))
                {
                    SPServiceContext context = SPServiceContext.GetContext(site);
                    UserProfileManager upm = new UserProfileManager(context);
                    UserProfile profile = upm.GetUserProfile("your user name here");
                    String WorkEmail = profile[PropertyConstants.WorkEmail].Value.ToString();
                    String FirstName = profile[PropertyConstants.FirstName].Value.ToString();
                    String LastName = profile[PropertyConstants.LastName].Value.ToString();
                }

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell