getControls() public method

Returns the controls to be sent to the server.
public getControls ( ) : Novell.Directory.Ldap.LdapControl[]
return Novell.Directory.Ldap.LdapControl[]
示例#1
0
        /// <summary> Constructs an LdapSearchConstraints object initialized with values
        /// from an existing constraints object (LdapConstraints
        /// or LdapSearchConstraints).
        /// </summary>
        public LdapSearchConstraints(LdapConstraints cons) : base(cons.TimeLimit, cons.ReferralFollowing, cons.getReferralHandler(), cons.HopLimit)
        {
            InitBlock();
            LdapControl[] lsc = cons.getControls();
            if (lsc != null)
            {
                LdapControl[] generated_var = new LdapControl[lsc.Length];
                lsc.CopyTo(generated_var, 0);
                setControls(generated_var);
            }
            System.Collections.Hashtable lp = cons.Properties;
            if (lp != null)
            {
                Properties = (System.Collections.Hashtable)lp.Clone();
            }

            if (cons is LdapSearchConstraints)
            {
                LdapSearchConstraints scons = (LdapSearchConstraints)cons;
                serverTimeLimit = scons.ServerTimeLimit;
                dereference     = scons.Dereference;
                maxResults      = scons.MaxResults;
                batchSize       = scons.BatchSize;
            }
            // Get a unique connection name for debug
        }
示例#2
0
        /// <summary> Constructs an LdapSearchConstraints object initialized with values
        /// from an existing constraints object (LdapConstraints
        /// or LdapSearchConstraints).
        /// </summary>
        public LdapSearchConstraints(LdapConstraints cons)
            : base(cons.TimeLimit, cons.ReferralFollowing, cons.getReferralHandler(), cons.HopLimit)
        {
            InitBlock();
            LdapControl[] lsc = cons.getControls();
            if (lsc != null)
            {
                LdapControl[] generated_var = new LdapControl[lsc.Length];
                lsc.CopyTo(generated_var, 0);
                base.setControls(generated_var);
            }
            Hashtable lp = cons.Properties;

            if (lp != null)
            {
                base.Properties = (Hashtable)lp.Clone();
            }

            if (cons is LdapSearchConstraints)
            {
                LdapSearchConstraints scons = (LdapSearchConstraints)cons;
                this.serverTimeLimit = scons.ServerTimeLimit;
                this.dereference     = scons.Dereference;
                this.maxResults      = scons.MaxResults;
                this.batchSize       = scons.BatchSize;
            }
        }
示例#3
0
        internal virtual void Abandon(LdapConstraints cons, InterThreadException informUserEx)
        {
            if (!waitForReply_Renamed_Field)
            {
                return ;
            }
            acceptReplies = false; // don't listen to anyone
            waitForReply_Renamed_Field = false; // don't let sleeping threads lie
            if (!complete)
            {
                try
                {
                    // If a bind, release bind semaphore & wake up waiting threads
                    // Must do before writing abandon message, otherwise deadlock
                    if (bindprops != null)
                    {
                        int id;
                        if (conn.BindSemIdClear)
                        {
                            // Semaphore id for normal operations
                            id = msgId;
                        }
                        else
                        {
                            // Semaphore id for sasl bind
                            id = conn.BindSemId;
                            conn.clearBindSemId();
                        }
                        conn.freeWriteSemaphore(id);
                    }

                    // Create the abandon message, but don't track it.
                    LdapControl[] cont = null;
                    if (cons != null)
                    {
                        cont = cons.getControls();
                    }
                    LdapMessage msg = new LdapAbandonRequest(msgId, cont);
                    // Send abandon message to server
                    conn.writeMessage(msg);
                }
                catch (LdapException ex)
                {
                    ; // do nothing
                }
                // If not informing user, remove message from agent
                if (informUserEx == null)
                {
                    agent.Abandon(msgId, null);
                }
                conn.removeMessage(this);
            }
            // Get rid of all replies queued
            if (informUserEx != null)
            {
                replies.Add(new LdapResponse(informUserEx, conn.ActiveReferral));
                stopTimer();
                // wake up waiting threads to receive exception
                sleepersAwake();
                // Message will get cleaned up when last response removed from queue
            }
            else
            {
                // Wake up any waiting threads, so they can terminate.
                // If informing the user, we wake sleepers after
                // caller queues dummy response with error status
                sleepersAwake();
                cleanup();
            }
            return ;
        }
        internal virtual void Abandon(LdapConstraints cons, InterThreadException informUserEx)
        {
            if (!waitForReply_Renamed_Field)
            {
                return;
            }
            acceptReplies = false;              // don't listen to anyone
            waitForReply_Renamed_Field = false; // don't let sleeping threads lie
            if (!complete)
            {
                try
                {
                    // If a bind, release bind semaphore & wake up waiting threads
                    // Must do before writing abandon message, otherwise deadlock
                    if (bindprops != null)
                    {
                        int id;
                        if (conn.BindSemIdClear)
                        {
                            // Semaphore id for normal operations
                            id = msgId;
                        }
                        else
                        {
                            // Semaphore id for sasl bind
                            id = conn.BindSemId;
                            conn.clearBindSemId();
                        }
                        conn.freeWriteSemaphore(id);
                    }

                    // Create the abandon message, but don't track it.
                    LdapControl[] cont = null;
                    if (cons != null)
                    {
                        cont = cons.getControls();
                    }
                    LdapMessage msg = new LdapAbandonRequest(msgId, cont);
                    // Send abandon message to server
                    conn.writeMessage(msg);
                }
                catch (LdapException ex)
                {
                    LogManager.GetCurrentClassLogger().Warn("Exception swallowed", ex);
                }
                // If not informing user, remove message from agent
                if (informUserEx == null)
                {
                    agent.Abandon(msgId, null);
                }
                conn.removeMessage(this);
            }
            // Get rid of all replies queued
            if (informUserEx != null)
            {
                replies.Add(new LdapResponse(informUserEx, conn.ActiveReferral));
                stopTimer();
                // wake up waiting threads to receive exception
                sleepersAwake();
                // Message will get cleaned up when last response removed from queue
            }
            else
            {
                // Wake up any waiting threads, so they can terminate.
                // If informing the user, we wake sleepers after
                // caller queues dummy response with error status
                sleepersAwake();
                cleanup();
            }
        }
示例#5
0
		/// <summary> Asynchronously renames an existing entry in the directory, using the
		/// specified constraints and possibily repositioning the entry in the
		/// directory.
		/// 
		/// </summary>
		/// <param name="dn">            The current distinguished name of the entry.
		/// 
		/// </param>
		/// <param name="newRdn">        The new relative distinguished name for the entry.
		/// 
		/// </param>
		/// <param name="newParentdn">   The distinguished name of an existing entry which
		/// is to be the new parent of the entry.
		/// 
		/// </param>
		/// <param name="deleteOldRdn">  If true, the old name is not retained as an
		/// attribute value. If false, the old name is
		/// retained as an attribute value.
		/// 
		/// </param>
		/// <param name="queue">         The queue for messages returned from a server in
		/// response to this request. If it is null, a
		/// queue object is created internally.
		/// 
		/// </param>
		/// <param name="cons">          The constraints specific to the operation.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// </exception>
		public virtual LdapResponseQueue Rename(System.String dn, System.String newRdn, System.String newParentdn, bool deleteOldRdn, LdapResponseQueue queue, LdapConstraints cons)
		{
			if ((System.Object) dn == null || (System.Object) newRdn == null)
			{
				// Invalid DN or RDN parameter
				throw new System.ArgumentException(ExceptionMessages.RDN_PARAM_ERROR);
			}
			
			if (cons == null)
				cons = defSearchCons;
			
			LdapMessage msg = new LdapModifyDNRequest(dn, newRdn, newParentdn, deleteOldRdn, cons.getControls());
			
			return SendRequestToServer(msg, cons.TimeLimit, queue, null);
		}
示例#6
0
		/// <summary> Asynchronously makes a set of changes to an existing entry in the
		/// directory, using the specified constraints and queue.
		/// 
		/// For example, this modify method can change attribute values, add new
		/// attribute values, or remove existing attribute values.
		/// 
		/// Because the server applies all changes in an LdapModification array
		/// atomically, the application can expect that no changes
		/// have been performed if an error is returned.
		/// If the request fails with {@link LdapException.CONNECT_ERROR},
		/// it is indeterminate whether or not the server made the modifications.
		/// 
		/// </summary>
		/// <param name="dn">        The distinguished name of the entry to modify.
		/// 
		/// </param>
		/// <param name="mods">      The changes to be made to the entry.
		/// 
		/// </param>
		/// <param name="queue">     The queue for messages returned from a server in
		/// response to this request. If it is null, a
		/// queue object is created internally.
		/// 
		/// </param>
		/// <param name="cons">      Constraints specific to the operation.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// </exception>
		public virtual LdapResponseQueue Modify(System.String dn, LdapModification[] mods, LdapResponseQueue queue, LdapConstraints cons)
		{
			if ((System.Object) dn == null)
			{
				// Invalid DN parameter
				throw new System.ArgumentException(ExceptionMessages.DN_PARAM_ERROR);
			}
			
			if (cons == null)
				cons = defSearchCons;
			
			LdapMessage msg = new LdapModifyRequest(dn, mods, cons.getControls());
			
			return SendRequestToServer(msg, cons.TimeLimit, queue, null);
		}
示例#7
0
		/// <summary> Formulates the extended operation, constraints into an
		/// LdapMessage and returns the LdapMessage.  This is used by
		/// extendedOperation and startTLS which needs the LdapMessage to
		/// get the MessageID.
		/// </summary>
		protected internal virtual LdapMessage MakeExtendedOperation(LdapExtendedOperation op, LdapConstraints cons)
		{
			// Use default constraints if none-specified
			if (cons == null)
				cons = defSearchCons;
			
			// error check the parameters
			if ((System.Object) op.getID() == null)
			{
				// Invalid extended operation parameter, no OID specified
				throw new System.ArgumentException(ExceptionMessages.OP_PARAM_ERROR);
			}
			
			return new LdapExtendedRequest(op, cons.getControls());
		}
示例#8
0
		/// <summary> Asynchronously compares an attribute value with one in the directory,
		/// using the specified queue and contraints.
		/// 
		/// Please note that a successful completion of this command results in
		/// one of two status codes: LdapException.COMPARE_TRUE if the entry
		/// has the value, and LdapException.COMPARE_FALSE if the entry
		/// does not have the value or the attribute.
		/// 
		/// </summary>
		/// <param name="dn">     The distinguished name of the entry containing an
		/// attribute to compare.
		/// 
		/// </param>
		/// <param name="attr">   An attribute to compare.
		/// 
		/// </param>
		/// <param name="queue">    Handler for messages returned from a server in
		/// response to this request. If it is null, a
		/// queue object is created internally.
		/// 
		/// </param>
		/// <param name="cons">     Constraints specific to the operation.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// 
		/// </exception>
		/// <seealso cref="LdapException.COMPARE_TRUE">
		/// </seealso>
		/// <seealso cref="LdapException.COMPARE_FALSE">
		/// </seealso>
		public virtual LdapResponseQueue Compare(System.String dn, LdapAttribute attr, LdapResponseQueue queue, LdapConstraints cons)
		{
			if (attr.size() != 1)
			{
				throw new System.ArgumentException("compare: Exactly one value " + "must be present in the LdapAttribute");
			}
			
			if ((System.Object) dn == null)
			{
				// Invalid parameter
				throw new System.ArgumentException("compare: DN cannot be null");
			}
			
			if (cons == null)
				cons = defSearchCons;
			
			LdapMessage msg = new LdapCompareRequest(dn, attr.Name, attr.ByteValue, cons.getControls());
			
			return SendRequestToServer(msg, cons.TimeLimit, queue, null);
		}
示例#9
0
		public virtual LdapResponseQueue Bind(int version, System.String dn, sbyte[] passwd, LdapResponseQueue queue, LdapConstraints cons, string mech)
		{
			int msgId;
			BindProperties bindProps;
			if (cons == null)
				cons = defSearchCons;
			
			if ((System.Object) dn == null)
			{
				dn = "";
			}
			else
			{
				dn = dn.Trim();
			}
			
			if (passwd == null)
				passwd = new sbyte[]{};
			
			bool anonymous = false;
			if (passwd.Length == 0)
			{
				anonymous = true; // anonymous, passwd length zero with simple bind
				dn = ""; // set to null if anonymous
			}

			LdapMessage msg;
#if TARGET_JVM
			if (mech != null)
				msg = new LdapBindRequest(version, "", mech, passwd, cons.getControls());
			else
#endif
				msg = new LdapBindRequest(version, dn, passwd, cons.getControls());
			
			msgId = msg.MessageID;
			bindProps = new BindProperties(version, dn, "simple", anonymous, null, null);
			
			// For bind requests, if not connected, attempt to reconnect
			if (!conn.Connected)
			{
				if ((System.Object) conn.Host != null)
				{
					conn.connect(conn.Host, conn.Port);
				}
				else
				{
					throw new LdapException(ExceptionMessages.CONNECTION_IMPOSSIBLE, LdapException.CONNECT_ERROR, null);
				}
			}
			
#if TARGET_JVM
			// stopping reader to enable stream replace after secure binding is complete, see Connection.ReplaceStreams()
			if (mech != null)
			{
				if (conn.BindSemIdClear) {
					// need to acquire a semaphore only if bindSemId is clear
					// because if we receive SASL_BIND_IN_PROGRESS the semaphore is not
					// released when the response is queued
					conn.acquireWriteSemaphore(msgId);
					conn.BindSemId = msgId;
				}
				conn.stopReaderOnReply(msgId);
			}
			else
#endif
			// The semaphore is released when the bind response is queued.
			conn.acquireWriteSemaphore(msgId);
			
			return SendRequestToServer(msg, cons.TimeLimit, queue, bindProps);
		}
示例#10
0
		/// <summary> Asynchronously adds an entry to the directory, using the specified
		/// constraints.
		/// 
		/// </summary>
		/// <param name="entry">  LdapEntry object specifying the distinguished
		/// name and attributes of the new entry.
		/// 
		/// </param>
		/// <param name="queue"> Handler for messages returned from a server in
		/// response to this request. If it is null, a
		/// queue object is created internally.
		/// 
		/// </param>
		/// <param name="cons">  Constraints specific to the operation.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// </exception>
		public virtual LdapResponseQueue Add(LdapEntry entry, LdapResponseQueue queue, LdapConstraints cons)
		{
			if (cons == null)
				cons = defSearchCons;
			
			// error check the parameters
			if (entry == null)
			{
				throw new System.ArgumentException("The LdapEntry parameter" + " cannot be null");
			}
			if ((System.Object) entry.DN == null)
			{
				throw new System.ArgumentException("The DN value must be present" + " in the LdapEntry object");
			}
			
			LdapMessage msg = new LdapAddRequest(entry, cons.getControls());
			
			return SendRequestToServer(msg, cons.TimeLimit, queue, null);
		}
示例#11
0
        public virtual LdapResponseQueue Bind(int version, System.String dn, sbyte[] passwd, LdapResponseQueue queue, LdapConstraints cons)
        {
            int msgId;
            BindProperties bindProps;
            if (cons == null)
                cons = defSearchCons;

            if ((System.Object) dn == null)
            {
                dn = "";
            }
            else
            {
                dn = dn.Trim();
            }

            if (passwd == null)
                passwd = new sbyte[]{};

            bool anonymous = false;
            if (passwd.Length == 0)
            {
                anonymous = true; // anonymous, passwd length zero with simple bind
                dn = ""; // set to null if anonymous
            }

            LdapMessage msg = new LdapBindRequest(version, dn, passwd, cons.getControls());

            msgId = msg.MessageID;
            bindProps = new BindProperties(version, dn, "simple", anonymous, null, null);

            // For bind requests, if not connected, attempt to reconnect
            if (!conn.Connected)
            {
                if ((System.Object) conn.Host != null)
                {
                    conn.connect(conn.Host, conn.Port);
                }
                else
                {
                    throw new LdapException(ExceptionMessages.CONNECTION_IMPOSSIBLE, LdapException.CONNECT_ERROR, null);
                }
            }

            // The semaphore is released when the bind response is queued.
            conn.acquireWriteSemaphore(msgId);

            return SendRequestToServer(msg, cons.TimeLimit, queue, bindProps);
        }
        /// <summary> Constructs an LdapSearchConstraints object initialized with values
        /// from an existing constraints object (LdapConstraints
        /// or LdapSearchConstraints).
        /// </summary>
        public LdapSearchConstraints(LdapConstraints cons)
            : base(cons.TimeLimit, cons.ReferralFollowing, cons.getReferralHandler(), cons.HopLimit)
        {
            InitBlock();
            LdapControl[] lsc = cons.getControls();
            if (lsc != null)
            {
                LdapControl[] generated_var = new LdapControl[lsc.Length];
                lsc.CopyTo(generated_var, 0);
                base.setControls(generated_var);
            }
            System.Collections.Hashtable lp = cons.Properties;
            if (lp != null)
            {
                base.Properties = (System.Collections.Hashtable) lp.Clone();
            }

            if (cons is LdapSearchConstraints)
            {
                LdapSearchConstraints scons = (LdapSearchConstraints) cons;
                this.serverTimeLimit = scons.ServerTimeLimit;
                this.dereference = scons.Dereference;
                this.maxResults = scons.MaxResults;
                this.batchSize = scons.BatchSize;
            }
            // Get a unique connection name for debug
            return ;
        }