//Updates a user profile
//Creates a user profile. Obtains the property values from the default
//domain controller or the master connection that is configured on the
//server
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using Microsoft.Office.Server;
using System.Web;
namespace UserProfilesApp
{
class Program
{
static void Main(string[] args)
{
try
{
using (SPSite site = new SPSite("http://servername"))
{
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);
string sAccount = "domainname\\username";
UserProfile u = profileManager.GetUserProfile(sAccount);
u[PropertyConstants.HomePhone].Value = "nnnnnnnnnn";
u[PropertyConstants.CellPhone].Value = "nnnnnnnnnn";
u.Commit();
}
}
catch (UserNotFoundException exception)
{
Console.WriteLine(exception.ToString());
}
}
}
}
http://msdn.microsoft.com/en-us/library/ms518939.aspx
http://archive.feedblitz.com/714474/~3937149
http://www.learningsharepoint.com/2010/07/19/programmatically-get-user-profile-picture-using-client-object-model-sharepoint-2010/
function getUserProfile(userID)
{
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var userInfoList = web.get_siteUserInfoList();
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘<View><Query><Where><Eq><FieldRef Name=\’ID\’/>’ +’<Value Type=\’Number\’>’ + userID + ‘</Value></Eq>’ +
‘</Where></Query><RowLimit>1</RowLimit></View>’);
this.collListItem = userInfoList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args)
{
var item = collListItem.itemAt(0);
var profile = item.get_item(‘Notes’);
var pictureUrl = item.get_item(‘Picture’).get_url();
var userImage = document.getElementById(‘myImageContainer’); -> Image object
userImage.src = pictureUrl;
var profileDiv = document.getElementById(‘userProfileContainer’);
profileDiv.innerHTML = profile;
}
Comments
Post a Comment