Friday, January 22, 2010

Custom Permissions based on MetaData

An interesting request came my way over the past couple of weeks. Could we provide capability to add security for lists based on MetaData columns. Reading a couple of blogs and information available online I am working on a solution that might provide a solution to our users. Stand by, if successful I will post the code online over the weekend for interested parties.

Thursday, January 14, 2010

Get Specific Folder using SP WebServcie and CAML Query

StringBuilder sbQuery = new StringBuilder(100);
sbQuery.Append("");
sbQuery.Append("<where> ");
sbQuery.Append(" <and>");
sbQuery.Append("<eq> ");
sbQuery.Append("<fieldref name="\">");
sbQuery.Append("<value type="\">1</value>");
sbQuery.Append("</eq>");
sbQuery.Append("<contains>");
sbQuery.Append("<fieldref name="\">");
sbQuery.Append(string.Format("<value type="\">{0}</value>", folderName));
sbQuery.Append("</contains>");
sbQuery.Append(" </and>");
sbQuery.Append("</where>>");
sbQuery.Append("</query>");
sbQuery.Append("<viewfields>");
sbQuery.Append("<fieldref name="\"><fieldref name="\"><fieldref name="\">");
sbQuery.Append("</viewfields>");
sbQuery.Append("<queryoptions>");
sbQuery.Append("<viewattributes scope="\">");
sbQuery.Append("</queryoptions>");
sbQuery.Append("</mylistitemrequest>");



//the key here is the Scope= RecursiveAll will return all folders including subfolders.
//string query = "1";


XmlDocument doc = new XmlDocument();
doc.LoadXml(sbQuery.ToString());

XmlNode queryNode = doc.SelectSingleNode("//Query");
XmlNode viewNode = doc.SelectSingleNode("//ViewFields");
XmlNode optionNode = doc.SelectSingleNode("//QueryOptions");

XmlNode retNode = _lists.GetListItems(listname, string.Empty, queryNode, viewNode, string.Empty, optionNode, string.Empty);


return GetItemId(retNode);