Beispiel #1
0
        public static AdamInstanceCollection FindAll(DirectoryContext context, string partitionName)
        {
            AdamInstanceCollection adamInstanceCollection;

            if (context != null)
            {
                if (context.ContextType == DirectoryContextType.ConfigurationSet)
                {
                    if (partitionName != null)
                    {
                        if (partitionName.Length != 0)
                        {
                            context = new DirectoryContext(context);
                            try
                            {
                                adamInstanceCollection = ConfigurationSet.FindAdamInstances(context, partitionName, null);
                            }
                            catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
                            {
                                adamInstanceCollection = new AdamInstanceCollection(new ArrayList());
                            }
                            return(adamInstanceCollection);
                        }
                        else
                        {
                            throw new ArgumentException(Res.GetString("EmptyStringParameter"), "partitionName");
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException("partitionName");
                    }
                }
                else
                {
                    throw new ArgumentException(Res.GetString("TargetShouldBeConfigSet"), "context");
                }
            }
            else
            {
                throw new ArgumentNullException("context");
            }
        }
        public static AdamInstanceCollection FindAll(DirectoryContext context, string partitionName)
        {
            AdamInstanceCollection adamInstanceCollection = null;

            // validate parameters (partitionName validated by the call to ConfigSet)
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // contexttype should be ConfigurationSet
            if (context.ContextType != DirectoryContextType.ConfigurationSet)
            {
                throw new ArgumentException(SR.TargetShouldBeConfigSet, nameof(context));
            }

            if (partitionName == null)
            {
                throw new ArgumentNullException(nameof(partitionName));
            }

            if (partitionName.Length == 0)
            {
                throw new ArgumentException(SR.EmptyStringParameter, nameof(partitionName));
            }

            //  work with copy of the context
            context = new DirectoryContext(context);

            try
            {
                adamInstanceCollection = ConfigurationSet.FindAdamInstances(context, partitionName, null);
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                // this is the case where  we could not find an ADAM instance in that config set (return empty collection)
                adamInstanceCollection = new AdamInstanceCollection(new ArrayList());
            }

            return(adamInstanceCollection);
        }
Beispiel #3
0
		public static AdamInstanceCollection FindAll(DirectoryContext context, string partitionName)
		{
			AdamInstanceCollection adamInstanceCollection;
			if (context != null)
			{
				if (context.ContextType == DirectoryContextType.ConfigurationSet)
				{
					if (partitionName != null)
					{
						if (partitionName.Length != 0)
						{
							context = new DirectoryContext(context);
							try
							{
								adamInstanceCollection = ConfigurationSet.FindAdamInstances(context, partitionName, null);
							}
							catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
							{
								adamInstanceCollection = new AdamInstanceCollection(new ArrayList());
							}
							return adamInstanceCollection;
						}
						else
						{
							throw new ArgumentException(Res.GetString("EmptyStringParameter"), "partitionName");
						}
					}
					else
					{
						throw new ArgumentNullException("partitionName");
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("TargetShouldBeConfigSet"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}
Beispiel #4
0
        public static AdamInstanceCollection FindAll(DirectoryContext context, string partitionName)
        {
            AdamInstanceCollection adamInstanceCollection = null;

            // validate parameters (partitionName validated by the call to ConfigSet)
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            // contexttype should be ConfigurationSet
            if (context.ContextType != DirectoryContextType.ConfigurationSet)
            {
                throw new ArgumentException(Res.GetString(Res.TargetShouldBeConfigSet), "context");
            }

            if (partitionName == null)
            {
                throw new ArgumentNullException("partitionName");
            }

            if (partitionName.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "partitionName");
            }

            //  work with copy of the context
            context = new DirectoryContext(context);

            try
            {
                adamInstanceCollection = ConfigurationSet.FindAdamInstances(context, partitionName, null);
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                // this is the case where  we could not find an ADAM instance in that config set (return empty collection)
                adamInstanceCollection = new AdamInstanceCollection(new ArrayList());
            }

            return adamInstanceCollection;
        }