I am throwing together a quick C# win forms app to help resolve a repetitive clerical job.
I have performed a search in AD for all user accounts and am adding them t
I came here looking for an answer, but it was only for DirectoryEntry
. So here is a code that works for SearchResult
/ SearchResultCollection
, for people who had the same problem:
private bool checkIfActive(SearchResult sr)
{
var vaPropertiy = sr.Properties["userAccountControl"];
if (vaPropertiy.Count > 0)
{
if (vaPropertiy[0].ToString() == "512" || vaPropertiy[0].ToString() == "66048")
{
return true;
}
return false;
}
return false;
}