string
strAccountName =
.Empty;
SPSite currentSite =
new
SPSite(SPContext.Current.Site.ID);
KeywordQuery peopleQuery =
KeywordQuery(currentSite);
peopleQuery.ResultsProvider = SearchProvider.SharepointSearch;
peopleQuery.RowLimit = 2;
peopleQuery.HiddenConstraints =
"scope:"
+
"\"People\""
;
peopleQuery.ResultTypes = ResultType.RelevantResults;
peopleQuery.QueryText =
"CustomId:"
+ strCustomId;
//where CustomId will the managed property and strCustimId will be the value of the search
peopleQuery.SelectProperties.Add(
"CustomID"
);
"AccountName"
ResultTableCollection resultCollection = peopleQuery.Execute();
if
(resultCollection.Exists(ResultType.RelevantResults))
{
ResultTable result = resultCollection[ResultType.RelevantResults];
DataTable tblResult =
DataTable();
tblResult.TableName =
"CustomIdMatch"
tblResult.Load(result, LoadOption.OverwriteChanges);
(tblResult.Rows.Count > 0)
strAccountName = Convert.ToString(tblResult.Rows[0][
]);
}