예제 #1
0
        /// <summary>
        /// Adds the detail.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="dataOWnerXML">The data O wner XML.</param>
        /// <param name="dataOwner">The data owner.</param>
        /// <param name="phoneElement">The phone element.</param>
        private void AddDetail(User user, ref XmlDocument dataOWnerXML, ref XmlElement dataOwner, ref XmlElement phoneElement)
        {
            XmlElement xmlelementDetail;
            XmlElement xmlelementDetailValue;
            XmlAttribute xmlattributeDetailName;
            XmlAttribute xmlattributeDetailValueName;
            bool blnAddPhoneNode = true;

            try
            {
                Type type = user.GetType();
                PropertyInfo[] propertyinfoCol = type.GetProperties();
                foreach (PropertyInfo propertyInfo in propertyinfoCol)
                {
                    if ((!propertyInfo.Name.ToLowerInvariant().Equals("userid")) && (!propertyInfo.Name.ToLowerInvariant().Equals("name")))
                    {
                        if ((propertyInfo.Name.ToLowerInvariant().Equals("telephonenumber")) || (propertyInfo.Name.ToLowerInvariant().Equals("mobilenumber")) || (propertyInfo.Name.ToLowerInvariant().Equals("othertelephonenumber")) || (propertyInfo.Name.ToLowerInvariant().Equals("extnnumber")))
                        {
                            for (int count = 0; count < dataOwner.ChildNodes.Count; count++)
                            {

                                if (dataOwner.ChildNodes.Item(count).Attributes[NAME].ToString().Equals("Phone"))
                                {
                                    blnAddPhoneNode = false;
                                    break;
                                }

                            }
                            if (blnAddPhoneNode)
                            {
                                dataOwner.AppendChild(phoneElement);
                            }
                            xmlelementDetailValue = dataOWnerXML.CreateElement(VALUE);
                            xmlattributeDetailValueName = dataOWnerXML.CreateAttribute(NAME);
                            xmlattributeDetailValueName.Value = GetDisplayName(propertyInfo.Name.ToLowerInvariant());
                            xmlelementDetailValue.Attributes.Append(xmlattributeDetailValueName);

                            xmlelementDetailValue.InnerText = propertyInfo.GetValue(user, null).ToString();
                            phoneElement.AppendChild(xmlelementDetailValue);
                        }
                        else
                        {

                            xmlelementDetail = dataOWnerXML.CreateElement(DETAIL);
                            xmlattributeDetailName = dataOWnerXML.CreateAttribute(NAME);

                            xmlattributeDetailName.Value = GetDisplayName(propertyInfo.Name.ToLowerInvariant());
                            xmlelementDetail.Attributes.Append(xmlattributeDetailName);

                            xmlelementDetailValue = dataOWnerXML.CreateElement(VALUE);
                            xmlattributeDetailValueName = dataOWnerXML.CreateAttribute(NAME);
                            xmlattributeDetailValueName.Value = string.Empty;
                            xmlelementDetailValue.Attributes.Append(xmlattributeDetailValueName);

                            xmlelementDetailValue.InnerText = propertyInfo.GetValue(user, null).ToString();
                            xmlelementDetail.AppendChild(xmlelementDetailValue);
                            dataOwner.AppendChild(xmlelementDetail);

                        }

                    }
                }
            }
            catch
            {
                throw;
            }
        }
예제 #2
0
파일: Users.cs 프로젝트: vijaymca/Dotnet
 /// <summary>
 /// Removes a User
 /// </summary>
 /// <param name="user">User object ot be removed from the Users collection</param>
 public void Remove(User user)
 {
     arlDataOwner.Remove(user);
 }
예제 #3
0
파일: Users.cs 프로젝트: vijaymca/Dotnet
 /// <summary>
 /// Adds a User
 /// </summary>
 /// <param name="user">User object to be added to Users collection</param>
 public void Add(User user)
 {
     arlDataOwner.Add(user);
 }
예제 #4
0
        /// 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();
            }
        }