Occasionally, in a search from AD I am getting System.Byte[] responses. If I open the source page file in vs2010 and resave the search returns with no problem.
Of Note I am binding the result set to xml. I am imagining that this has a-lot to do with it.
Here is a code-excerpt:
public void bindGridView(string sortExp, string sortOrder)
{
DataSet aDataSet = new DataSet();
XmlDocument xd = LDAPConn(sortExp, sortOrder);
aDataSet.ReadXml(new StringReader(xd.InnerXml));
// Bind the DataSet to the grid view
DataView dv = new DataView();
string sortMsg = "";
switch (sortExp)
{
case "sn":
sortMsg = "Lastname";
break;
case "department":
sortMsg = "Department";
break;
case "Title":
sortMsg = "Title";
break;
case "physicalDeliveryOfficeName":
sortMsg = "Store";
break;
default:
sortMsg = sortExp;
break;
}
if (aDataSet.Tables.Count > 0)
{
try
{
debug(true, "<h2 style='float:right;'><b>Sorting By:</b><strong style='color:#880000;'>" + sortMsg + "</strong> & <b>Direction:</b><strong style='color:#880000;'>" + sortOrder.ToString() + "</strong></h2>");
dv = aDataSet.Tables[0].DefaultView;
GridView1.DataSource = dv;
GridView1.DataBind();
}
catch (Exception e)
{
debug(true, "<br/><b style='color: rgb(255,0,0);'>Your search returned no results.</b><br/><span style=''>" + e.Message + "<br/>" + e.InnerException + e.Source + "</span>");
}
}
}
I decided to just sanitize the field if string eval = System.Byte[]
public string SanitizeField(SearchResultCollection result, string field)
{
StringBuilder sb = new StringBuilder();
foreach (object val in result[0].Properties[field])
{
sb.Append("<" + field + ">" + val + "</" + field + ">");
}
return sb.ToString();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.