Example #1
0
 /// <summary>
 /// Возвращает все группы из AD, имена которых удовлетворяют заданному фильтру
 /// </summary>
 /// <param name="groupFilter">Фильтр по имени группы.</param>
 /// <param name="args"></param>
 /// <returns></returns>
 public ADGroupCollection FindGroups( string groupFilter )
 {
     try
     {
         using (DirectoryEntry entry = new DirectoryEntry( _groupPath, LdapUserName,
             ConfigurationManager.AppSettings["LdapPassword"] ))
         using (DirectorySearcher searcher = new DirectorySearcher( entry ))
         {
             searcher.SearchScope = SearchScope.Subtree;
             searcher.Filter = String.Format( @"(&(objectCategory=group)(name={0}))", groupFilter );
             ADGroupCollection groups = new ADGroupCollection();
             try
             {
                 foreach (SearchResult result in searcher.FindAll())
                     groups.Add( new ADGroup( result ) );
             }
             catch (ArgumentException) { } // неверная строка поиска
             return groups;
         }
     }
     catch (Exception ex)
     {
         throw new CoreApplicationException(Resources.ResourceManager.GetString("ErrorSearchingGroupException"), ex);
     }
 }
Example #2
0
		/// <summary>
		/// This method will return a list of objects representing all records in the table.
		/// </summary>
		///
		/// <returns>list of objects of class ADGroup in the form of object of ADGroupCollection </returns>
		public ADGroupCollection SelectAll()
		{
			ADGroupCollection aDGroupCollection = new ADGroupCollection();
			foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectAll())
			{
				_aDGroupWCF = new ADGroup();
				
				_aDGroupWCF.GroupID = _aDGroup.GroupID;
				_aDGroupWCF.GroupName = _aDGroup.GroupName;
				
				aDGroupCollection.Add(_aDGroupWCF);
			}
			return aDGroupCollection;
		}
Example #3
0
        /// <summary>
        /// This method will return a list of objects representing all records in the table.
        /// </summary>
        ///
        /// <returns>list of objects of class ADGroup in the form of object of ADGroupCollection </returns>
        public ADGroupCollection SelectAll()
        {
            ADGroupCollection aDGroupCollection = new ADGroupCollection();

            foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectAll())
            {
                _aDGroupWCF = new ADGroup();

                _aDGroupWCF.GroupID   = _aDGroup.GroupID;
                _aDGroupWCF.GroupName = _aDGroup.GroupName;

                aDGroupCollection.Add(_aDGroupWCF);
            }
            return(aDGroupCollection);
        }
Example #4
0
        /// <summary>
        /// This method will return a list of objects representing the specified number of entries from the specified record number in the table
        /// using the value of the field specified
        /// </summary>
        ///
        /// <param name="field" type="string">Field of the class ADGroup</param>
        /// <param name="fieldValue" type="object">Value for the field specified.</param>
        /// <param name="fieldValue2" type="object">Value for the field specified.</param>
        /// <param name="typeOperation" type="TypeOperation">Operator that is used if fieldValue2=null or fieldValue2="".</param>
        /// <param name="orderByStatement" type="string">The field value to number.</param>
        /// <param name="pageSize" type="int">Number of records returned.</param>
        /// <param name="skipPages" type="int">The number of missing pages.</param>
        ///
        /// <returns>List of object of class ADGroup in the form of an object of class ADGroupCollection</returns>
        public ADGroupCollection SelectByFieldPaged(string field, object fieldValue, object fieldValue2, TypeOperation typeOperation, int pageSize, int skipPages, string orderByStatement)
        {
            ADGroupCollection aDGroupCollection = new ADGroupCollection();

            foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectByFieldPaged(field, fieldValue, fieldValue2, typeOperation, pageSize, skipPages, orderByStatement))
            {
                _aDGroupWCF = new ADGroup();

                _aDGroupWCF.GroupID   = _aDGroup.GroupID;
                _aDGroupWCF.GroupName = _aDGroup.GroupName;

                aDGroupCollection.Add(_aDGroupWCF);
            }
            return(aDGroupCollection);
        }
Example #5
0
        /// <summary>
        /// This method will return a list of objects representing the specified number of entries from the specified record number in the table.
        /// </summary>
        ///
        /// <param name="pageSize" type="int">Number of records returned.</param>
        /// <param name="skipPages" type="int">The number of missing pages.</param>
        /// <param name="orderByStatement" type="string">The field value to number.</param>
        ///
        /// <returns>list of objects of class ADGroup in the form of an object of class ADGroupCollection </returns>
        public ADGroupCollection SelectAllPaged(int?pageSize, int?skipPages, string orderByStatement)
        {
            ADGroupCollection aDGroupCollection = new ADGroupCollection();

            foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectAllPaged(pageSize, skipPages, orderByStatement))
            {
                _aDGroupWCF = new ADGroup();

                _aDGroupWCF.GroupID   = _aDGroup.GroupID;
                _aDGroupWCF.GroupName = _aDGroup.GroupName;

                aDGroupCollection.Add(_aDGroupWCF);
            }
            return(aDGroupCollection);
        }
Example #6
0
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified
        /// </summary>
        ///
        /// <param name="field" type="string">Field of the class ADGroup</param>
        /// <param name="fieldValue" type="object">Value for the field specified.</param>
        /// <param name="fieldValue2" type="object">Value for the field specified.</param>
        /// <param name="typeOperation" type="TypeOperation">Operator that is used if fieldValue2=null or fieldValue2="".</param>
        ///
        /// <returns>List of object of class ADGroup in the form of an object of class ADGroupCollection</returns>
        public ADGroupCollection SelectByField(string field, object fieldValue, object fieldValue2, TypeOperation typeOperation)
        {
            ADGroupCollection aDGroupCollection = new ADGroupCollection();

            foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectByField(field, fieldValue, fieldValue2, typeOperation))
            {
                _aDGroupWCF = new ADGroup();

                _aDGroupWCF.GroupID   = _aDGroup.GroupID;
                _aDGroupWCF.GroupName = _aDGroup.GroupName;

                aDGroupCollection.Add(_aDGroupWCF);
            }
            return(aDGroupCollection);
        }
Example #7
0
		/// <summary>
		/// Populates the fields for multiple objects from the columns found in an open reader.
		/// </summary>
		///
		/// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
		///
		/// <returns>Object of ADGroupCollection</returns>
		///
		/// <remarks>
		///
		/// <RevisionHistory>
		/// Author				Date			Description
		/// DLGenerator			3/7/2015 2:37:00 PM		Created function
		/// 
		/// </RevisionHistory>
		///
		/// </remarks>
		///
		internal static ADGroupCollection PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper) 
		{

			ADGroupCollection list = new ADGroupCollection();
			
            if (rdr.Read())
			{
				ADGroup obj = new ADGroup();
				PopulateObjectFromReader(obj, rdr);
				list.Add(obj);
				while (rdr.Read())
				{
					obj = new ADGroup();
					PopulateObjectFromReader(obj, rdr);
					list.Add(obj);
				}
				oDatabaseHelper.Dispose();
				return list;
			}
			else
			{
				oDatabaseHelper.Dispose();
				return null;
			}
			
		}
Example #8
0
		/// <summary>
		/// Populates the fields for multiple objects from the columns found in an open reader.
		/// </summary>
		///
		/// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
		///
		/// <returns>Object of ADGroupCollection</returns>
		///
		/// <remarks>
		///
		/// <RevisionHistory>
		/// Author				Date			Description
		/// DLGenerator			3/7/2015 2:37:00 PM		Created function
		/// 
		/// </RevisionHistory>
		///
		/// </remarks>
		///
		internal static ADGroupCollection PopulateObjectsFromReader(IDataReader rdr) 
		{
			ADGroupCollection list = new ADGroupCollection();
			
			while (rdr.Read())
			{
				ADGroup obj = new ADGroup();
				PopulateObjectFromReader(obj,rdr);
				list.Add(obj);
			}
			return list;
			
		}
Example #9
0
		/// <summary>
		/// This method will get row(s) from the database using the value of the field specified
		/// </summary>
		///
		/// <param name="field" type="string">Field of the class ADGroup</param>
		/// <param name="fieldValue" type="object">Value for the field specified.</param>
		/// <param name="fieldValue2" type="object">Value for the field specified.</param>
		/// <param name="typeOperation" type="TypeOperation">Operator that is used if fieldValue2=null or fieldValue2="".</param>
		///
		/// <returns>List of object of class ADGroup in the form of an object of class ADGroupCollection</returns>
		public ADGroupCollection SelectByField(string field, object fieldValue, object fieldValue2, TypeOperation typeOperation)
		{
			ADGroupCollection aDGroupCollection = new ADGroupCollection();
			foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectByField(field, fieldValue, fieldValue2, typeOperation))
			{
				_aDGroupWCF = new ADGroup();
				
				_aDGroupWCF.GroupID = _aDGroup.GroupID;
				_aDGroupWCF.GroupName = _aDGroup.GroupName;
				
				aDGroupCollection.Add(_aDGroupWCF);
			}
			return aDGroupCollection;
		}
Example #10
0
		/// <summary>
		/// This method will return a list of objects representing the specified number of entries from the specified record number in the table 
		/// using the value of the field specified
		/// </summary>
		///
		/// <param name="field" type="string">Field of the class ADGroup</param>
		/// <param name="fieldValue" type="object">Value for the field specified.</param>
		/// <param name="fieldValue2" type="object">Value for the field specified.</param>
		/// <param name="typeOperation" type="TypeOperation">Operator that is used if fieldValue2=null or fieldValue2="".</param>
		/// <param name="orderByStatement" type="string">The field value to number.</param>
		/// <param name="pageSize" type="int">Number of records returned.</param>
		/// <param name="skipPages" type="int">The number of missing pages.</param>
		///
		/// <returns>List of object of class ADGroup in the form of an object of class ADGroupCollection</returns>
		public ADGroupCollection SelectByFieldPaged(string field, object fieldValue, object fieldValue2, TypeOperation typeOperation, int pageSize, int skipPages, string orderByStatement)
		{
			ADGroupCollection aDGroupCollection = new ADGroupCollection();
			foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectByFieldPaged(field, fieldValue, fieldValue2, typeOperation, pageSize, skipPages, orderByStatement))
			{
				_aDGroupWCF = new ADGroup();
				
				_aDGroupWCF.GroupID = _aDGroup.GroupID;
				_aDGroupWCF.GroupName = _aDGroup.GroupName;
				
				aDGroupCollection.Add(_aDGroupWCF);
			}
			return aDGroupCollection;
		}
Example #11
0
		/// <summary>
		/// This method will return a list of objects representing the specified number of entries from the specified record number in the table.
		/// </summary>
		///
		/// <param name="pageSize" type="int">Number of records returned.</param>
		/// <param name="skipPages" type="int">The number of missing pages.</param>
		/// <param name="orderByStatement" type="string">The field value to number.</param>
		///
		/// <returns>list of objects of class ADGroup in the form of an object of class ADGroupCollection </returns>
		public ADGroupCollection SelectAllPaged(int? pageSize, int? skipPages, string orderByStatement)
		{
			ADGroupCollection aDGroupCollection = new ADGroupCollection();
			foreach (POS.DataLayer.ADGroup _aDGroup in POS.DataLayer.ADGroupBase.SelectAllPaged(pageSize, skipPages, orderByStatement))
			{
				_aDGroupWCF = new ADGroup();
				
				_aDGroupWCF.GroupID = _aDGroup.GroupID;
				_aDGroupWCF.GroupName = _aDGroup.GroupName;
				
				aDGroupCollection.Add(_aDGroupWCF);
			}
			return aDGroupCollection;
		}
Example #12
0
 /// <summary>
 /// Возвращает постранично группы из AD, имена которых удовлетворяют заданному фильтру
 /// </summary>
 /// <param name="groupFilter">Фильтр по имени группы.</param>
 /// <param name="args"></param>
 /// <returns></returns>
 public PagingResult FindGroups( string groupFilter, PagingArgs args )
 {
     try
     {
         using (DirectoryEntry entry = new DirectoryEntry( _groupPath, LdapUserName,
             ConfigurationManager.AppSettings["LdapPassword"] ))
         using (DirectorySearcher searcher = new DirectorySearcher( entry ))
         {
             searcher.SearchScope = SearchScope.Subtree;
             searcher.Sort.PropertyName = ADGroup.GetADPropertyName( args.SortExpression );
             searcher.Sort.Direction = args.SortOrderASC ? SortDirection.Ascending : SortDirection.Descending;
             searcher.Filter = String.Format( @"(&(objectCategory=group)(name={0}))", groupFilter );
             ADGroupCollection groups = new ADGroupCollection();
             try
             {
                 foreach (SearchResult result in searcher.FindAll())
                     groups.Add( new ADGroup( result ) );
             }
             catch (ArgumentException) { } // неверная строка поиска
             return groups.GetPage( args );
         }
     }
     catch (Exception ex)
     {
         throw new CoreApplicationException(Resources.ResourceManager.GetString("ErrorSearchingGroupException"), ex);
     }
 }
Example #13
0
        /// <summary>
        /// Возвращает список групп, членом которым является указанный пользователь
        /// </summary>
        /// <param name="userName">Имя пользователя (login name без указания домена)</param>
        /// <returns></returns>
        public ADGroupCollection GetUserGroupsMembeship( string userName )
        {
            ADGroupCollection groups = new ADGroupCollection();

            SearchResult searchResult = FindUserEntry( userName );
            foreach (string groupDn in searchResult.Properties["memberOf"])
            {
                ADGroup group = new ADGroup();
                group.DN = groupDn;
                groups.Add( group );
            }

            return groups;
        }