public static Person GetAccount(string accountId) { if (_searchRoot == null) { throw new Exception("Invalid search path or search path not set"); } SecurityIdentifier sid = new SecurityIdentifier(accountId); _searcher.Filter = $"(&(objectClass=person)(objectSid={sid.ToHexString()}))"; using (SearchResultCollection collection = _searcher.FindAll()) { if (collection != null && collection.Count > 0) { return(new Person(collection[0])); } } return(null); }