private static ActiveDirectoryUserInfo FillUserInfo(SearchResult searchResult) { var userInfo = new ActiveDirectoryUserInfo(); var resultCollection = searchResult.Properties["mail"]; foreach (var result in resultCollection) { userInfo.Mail = result.ToString(); } resultCollection = searchResult.Properties["memberOf"]; var memberOf = new List <string>(); foreach (object result in resultCollection) { memberOf.Add(result.ToString()); } userInfo.MemberOf = memberOf.HasItems() ? memberOf.ToArray() : null; resultCollection = searchResult.Properties["name"]; foreach (object result in resultCollection) { userInfo.Name = result.ToString(); } resultCollection = searchResult.Properties["sAMAccountName"]; foreach (object result in resultCollection) { userInfo.Login = result.ToString(); } return(userInfo); }
private static ActiveDirectoryUserInfo FillUserInfo(SearchResult searchResult) { var userInfo = new ActiveDirectoryUserInfo(); userInfo.Mail = searchResult.Properties["mail"].ReadValue(); userInfo.MemberOf = searchResult.Properties["memberOf"].ReadValues(); userInfo.Name = searchResult.Properties["name"].ReadValue(); userInfo.Login = searchResult.Properties["sAMAccountName"].ReadValue(); userInfo.FirstName = searchResult.Properties["givenname"].ReadValue(); userInfo.LastName = searchResult.Properties["sn"].ReadValue(); userInfo.Properties = searchResult.Properties.ReadValues(); return(userInfo); }