/// <summary> /// Gets the data owner XML. /// </summary> /// <param name="users">The users.</param> /// <returns></returns> public XmlDocument GetDataOwnerXML(Users users, string[] dataSourceNames) { XmlDocument objResultXml = new XmlDocument(); XmlElement xmlelementDataOwners; XmlElement xmlelementDataOwner; XmlElement xmlelementPhoneDetail; XmlAttribute xmlattributeName; XmlAttribute xmlattributeDataSource; XmlAttribute xmlattributeDetailName; try { XmlDeclaration xmlDeclaration = objResultXml.CreateXmlDeclaration(XMLVERSION, ENCODING, string.Empty); objResultXml.AppendChild(xmlDeclaration); xmlelementDataOwners = objResultXml.CreateElement(DATAOWNERS); objResultXml.AppendChild(xmlelementDataOwners); for (int intCount = 0; intCount < users.Count; intCount++) { xmlelementDataOwner = objResultXml.CreateElement(DATAOWNER); xmlattributeName = objResultXml.CreateAttribute(USERDISPLAYNAME); xmlattributeName.Value = users[intCount].Name; xmlelementDataOwner.Attributes.Append(xmlattributeName); //Adding datasource attribute xmlattributeDataSource = objResultXml.CreateAttribute(DATASOURCE); // xmlattributeDataSource.Value = GetDataSourceName(users[intCount].UserID); xmlattributeDataSource.Value = dataSourceNames[intCount]; xmlelementDataOwner.Attributes.Append(xmlattributeDataSource); //adding phone detail element xmlelementPhoneDetail = objResultXml.CreateElement(DETAIL); xmlattributeDetailName = objResultXml.CreateAttribute(NAME); xmlattributeDetailName.Value = GetDisplayName("phone"); xmlelementPhoneDetail.Attributes.Append(xmlattributeDetailName); AddDetail(users[intCount], ref objResultXml, ref xmlelementDataOwner, ref xmlelementPhoneDetail); xmlelementDataOwners.AppendChild(xmlelementDataOwner); } } catch { throw; } return objResultXml; }
/// modified by dev for dataowner module /// <summary> /// This method is used to fetch specific details of users from active directory /// </summary> /// <param name="userIDs"> array of userIDs</param> /// <returns>collection of users</returns> public Users GetUserDetails(string[] userIDs) { Users objUsers = new Users(); User objUser; DirectorySearcher dirSearcher = null; DirectoryEntry dirEntry = null; SearchResult objResults = null; try { dirEntry = GetDirectoryObject("/" + GetLDAPDomain()); dirSearcher = new DirectorySearcher(dirEntry); dirSearcher.ClientTimeout = TimeSpan.FromSeconds(30); dirSearcher.SearchScope = SearchScope.Subtree; for(int intCount = 0; intCount < userIDs.Length; intCount++) { dirSearcher.Filter = "(SAMAccountName=" + userIDs[intCount] + ")"; objResults = dirSearcher.FindOne(); if(!(objResults == null)) { objUser = new User(); ResultPropertyCollection propColl = objResults.Properties; foreach(string strKey in Enum.GetNames(typeof(ADPropertyKeys))) { try { if((propColl[strKey] != null) && (propColl[strKey][0] != null)) { objUser.AddUserProperty(strKey.ToLower(), propColl[strKey][0].ToString()); } } //Added in DREAM 4.0 to handle indexout of bound error for unknown properties catch { objUser.AddUserProperty(strKey.ToLower(), string.Empty); } } objUsers.Add(objUser); } } return objUsers; } finally { if(dirEntry != null) dirEntry.Dispose(); if(dirSearcher != null) dirSearcher.Dispose(); } }