How to delete a user from Sharepoint 2010 using client object model.
My code is as below:
ClientContex ctx =newClientContext(http://contoso.com);
Webweb = ctx.Web;Listolist = ctx.Web.SiteUserInfoList;
ctx.Load(web);
ctx.ExecuteQuery();
CamlQuerycamlQry =newCamlQuery();
camlQry.ViewXml =
@"<View>
<Query>
<Where>
<BeginsWith>
<FieldRef Name='Name'/>
<Value Type='Text'>DomainName\UserName</Value>
</BeginsWith>
</Where>
</Query>
</View>"
;
ListItemCollectionlist Items = olist.GetItems(camlQry);
ctx.Load(olist);
ctx.Load(listItems);
ctx.ExecuteQuery();
foreach(ListItemiteminlistItems)
{
ctx.Load(item);
ctx.ExecuteQuery();
item.DeleteObject();
ctx.ExecuteQuery();
}
I get the error as Cannot complete this action at the last line. i.e ctx.ExecuteQuery(). I found in the net and as such it says that it might be because of caml query not declared properly. I even checked the caml query and there is no problem in it? Can anyone help.