Here is a simple example of how to remove a user (current user in our case) from User Information list using ECMAScript\JavaScript Client Object model.
function DeleteUser()
{
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
//Get User Info List
var userInfoList = web.get_siteUserInfoList();
context.load(userInfoList);
//Get Current user ID - Current UserId in a Site is the ID column of the user item in User Info List.
this._currentUser = web.get_currentUser();
context.load(this._currentUser);
var UserID = _currentUser.get_id();
var itemToDelete = userInfoList.getItemById(UserID);
itemToDelete.deleteObject();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args)
{
alert("User Deleted");
}
function onQueryFailed(sender, args)
{
alert("Delete Failed");
}
}
Ads by Google
Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.
ReplyDeleteSharepoint helpdesk