Наследование: Asn1Encoder
Пример #1
0
		/// <summary> 
		/// Constructs an extended operation object for receiving all updates from
		/// another directory server for a specific replica.
		/// 
		/// </summary>
		/// <param name="partitionRoot">  The distinguished name of the replica
		/// that will be updated.
		/// 
		/// </param>
		/// <param name="toServerDN">     The distinguished name of the server holding the
		/// replica to be updated.
		/// 
		/// </param>
		/// <param name="fromServerDN">   The distinguished name of the server from which
		/// updates are sent.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error message
		/// and an Ldap error code.
		/// </exception>
		public ReceiveAllUpdatesRequest(System.String partitionRoot, System.String toServerDN, System.String fromServerDN):base(ReplicationConstants.RECEIVE_ALL_UPDATES_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) partitionRoot == null) || ((System.Object) toServerDN == null) || ((System.Object) fromServerDN == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_partitionRoot = new Asn1OctetString(partitionRoot);
				Asn1OctetString asn1_toServerDN = new Asn1OctetString(toServerDN);
				Asn1OctetString asn1_fromServerDN = new Asn1OctetString(fromServerDN);
				
				asn1_partitionRoot.encode(encoder, encodedData);
				asn1_toServerDN.encode(encoder, encodedData);
				asn1_fromServerDN.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
Пример #2
0
		/// <summary> 
		/// Constructs an extended operation object for creating an orphan partition.
		/// 
		/// 
		/// </summary>
		/// <param name="serverDN">   The distinguished name of the server on which
		/// the new orphan partition will reside.
		/// 
		/// </param>
		/// <param name="contextName">The distinguished name of the
		/// new orphan partition.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error message
		/// and an Ldap error code.
		/// </exception>
		public SplitOrphanPartitionRequest(System.String serverDN, System.String contextName):base(ReplicationConstants.CREATE_ORPHAN_NAMING_CONTEXT_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) serverDN == null) || ((System.Object) contextName == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
				Asn1OctetString asn1_contextName = new Asn1OctetString(contextName);
				
				asn1_serverDN.encode(encoder, encodedData);
				asn1_contextName.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
Пример #3
0
		/// <summary> 
		/// Constructs an extended operation object for synchronizing the replicas
		/// of a partition.
		/// 
		/// </summary>
		/// <param name="serverName">    The distinquished name of server containing the
		/// naming context.
		/// 
		/// </param>
		/// <param name="partitionRoot"> The distinguished name of the naming context
		/// to synchronize.
		/// 
		/// </param>
		/// <param name="delay">         The time, in seconds, to delay before the synchronization
		/// should start.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error message
		/// and an Ldap error code.
		/// </exception>
		public PartitionSyncRequest(System.String serverName, System.String partitionRoot, int delay):base(ReplicationConstants.NAMING_CONTEXT_SYNC_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) serverName == null) || ((System.Object) partitionRoot == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);
				Asn1OctetString asn1_partitionRoot = new Asn1OctetString(partitionRoot);
				Asn1Integer asn1_delay = new Asn1Integer(delay);
				
				asn1_serverName.encode(encoder, encodedData);
				asn1_partitionRoot.encode(encoder, encodedData);
				asn1_delay.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
		/// <summary> Constructs an extended operation object for aborting a partition operation.
		/// 
		/// </summary>
		/// <param name="partitionDN">The distinguished name of the replica's
		/// partition root.
		/// 
		/// </param>
		/// <param name="flags">Determines whether all servers in the replica ring must
		/// be up before proceeding. When set to zero, the status of the
		/// servers is not checked. When set to Ldap_ENSURE_SERVERS_UP,
		/// all servers must be up for the operation to proceed.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error message
		/// and an Ldap error code.
		/// </exception>
		public AbortPartitionOperationRequest(System.String partitionDN, int flags):base(ReplicationConstants.ABORT_NAMING_CONTEXT_OP_REQ, null)
		{
			
			try
			{
				
				if ((System.Object) partitionDN == null)
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				
				Asn1Integer asn1_flags = new Asn1Integer(flags);
				Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN);
				
				asn1_flags.encode(encoder, encodedData);
				asn1_partitionDN.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
Пример #5
0
		private void  InitBlock()
		{
			writeSemaphore = new System.Object();
			encoder = new LBEREncoder();
			decoder = new LBERDecoder();
			stopReaderMessageID = CONTINUE_READING;
			messages = new MessageVector(5, 5);
			unsolicitedListeners = new System.Collections.ArrayList(3);
		}
Пример #6
0
    } // end of static constructor

    public MonitorEventRequest(EdirEventSpecifier[] specifiers) :
      base(EventOids.NLDAP_MONITOR_EVENTS_REQUEST, null)
    {
      if ((specifiers == null)) 
      {
	throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
      }

      MemoryStream encodedData = new MemoryStream();
      LBEREncoder encoder = new LBEREncoder();

      Asn1Sequence asnSequence = new Asn1Sequence();
      try
      {
	asnSequence.add(new Asn1Integer(specifiers.Length));

	Asn1Set asnSet = new Asn1Set();
	bool bFiltered = false;
	for (int nIndex = 0; nIndex < specifiers.Length; nIndex++)
	{
	  Asn1Sequence specifierSequence = new Asn1Sequence();
	  specifierSequence.add(new Asn1Integer((int)(specifiers[nIndex].EventType)));
	  specifierSequence.add(new Asn1Enumerated((int)(specifiers[nIndex].EventResultType)));
	  if (0 == nIndex)
	  {
	    bFiltered = (null != specifiers[nIndex].EventFilter);
	    if (bFiltered)
	      setID(EventOids.NLDAP_FILTERED_MONITOR_EVENTS_REQUEST);
	  }
	  
	  if (bFiltered)
	  {
	    // A filter is expected
	    if (null == specifiers[nIndex].EventFilter)
	      throw new ArgumentException("Filter cannot be null,for Filter events");

	    specifierSequence.add(new Asn1OctetString(specifiers[nIndex].EventFilter));
	  }
	  else
	  {
	    // No filter is expected
	    if (null != specifiers[nIndex].EventFilter)
	      throw new ArgumentException("Filter cannot be specified for non Filter events");	 
	  }

	  asnSet.add(specifierSequence);
	}

	asnSequence.add(asnSet);
	asnSequence.encode(encoder, encodedData);
      }
      catch(Exception e)
      {
	throw new LdapException(ExceptionMessages.ENCODING_ERROR,
				LdapException.ENCODING_ERROR, 
				null);
      }

      setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
    } // end of the constructor MonitorEventRequest
Пример #7
0
        /// <summary>  Constructs an extended operation object for listing replicas.
        /// 
        /// </summary>
        /// <param name="serverName">The server which contains replicas.
        /// 
        /// </param>
        /// <exception> LdapException A general exception which includes an error
        /// message and an Ldap error code.
        /// </exception>
        public ListReplicasRequest(System.String serverName)
            : base(ReplicationConstants.LIST_REPLICAS_REQ, null)
        {
            try
            {

                if ((System.Object) serverName == null)
                    throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);

                System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
                LBEREncoder encoder = new LBEREncoder();

                Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);

                asn1_serverName.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (System.IO.IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
            }
        }
Пример #8
0
		/// <summary> 
		/// Constructs an extended operations object which contains the ber encoded
		/// replication filter.
		/// 
		/// </summary>
		/// <param name="serverDN">The server on which the replication filter needs to be set
		/// 
		/// </param>
		/// <param name="replicationFilter">An array of String Arrays. Each array starting with
		/// a class name followed by the attribute names for that class that should comprise
		/// the replication filter.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// </exception>
		public SetReplicationFilterRequest(System.String serverDN, System.String[][] replicationFilter):base(ReplicationConstants.SET_REPLICATION_FILTER_REQ, null)
		{
			
			try
			{
				
				if ((System.Object) serverDN == null)
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
				
				// Add the serverDN to encoded data
				asn1_serverDN.encode(encoder, encodedData);
				
				// The toplevel sequenceOF
				Asn1SequenceOf asn1_replicationFilter = new Asn1SequenceOf();
				
				if (replicationFilter == null)
				{
					asn1_replicationFilter.encode(encoder, encodedData);
					setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
					return ;
				}
				
				int i = 0;
				// for every element in the array
				while ((i < replicationFilter.Length) && (replicationFilter[i] != null))
				{
					
					
					// The following additional Sequence is not needed
					// as defined by the Asn1. But the server and the
					// C client are encoding it. Remove this when server
					// and C client are fixed to conform to the published Asn1.
					Asn1Sequence buginAsn1Representation = new Asn1Sequence();
					
					// Add the classname to the sequence -
					buginAsn1Representation.add(new Asn1OctetString(replicationFilter[i][0]));
					
					// Start a sequenceOF for attributes
					Asn1SequenceOf asn1_attributeList = new Asn1SequenceOf();
					
					// For every attribute in the array - remember attributes start after
					// the first element
					int j = 1;
					while ((j < replicationFilter[i].Length) && ((System.Object) replicationFilter[i][j] != null))
					{
						
						// Add the attribute name to the inner SequenceOf
						asn1_attributeList.add(new Asn1OctetString(replicationFilter[i][j]));
						j++;
					}
					
					
					// Add the attributeList to the sequence - extra add due to bug
					buginAsn1Representation.add(asn1_attributeList);
					asn1_replicationFilter.add(buginAsn1Representation);
					i++;
				}
				
				asn1_replicationFilter.encode(encoder, encodedData);
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
Пример #9
0
		/// <summary>  Constructs an extended operation object for counting entries
		/// in a naming context.
		/// 
		/// </summary>
		/// <param name="dn"> The distinguished name of the partition.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an
		/// error message and an Ldap error code.
		/// </exception>
		
		public PartitionEntryCountRequest(System.String dn):base(ReplicationConstants.NAMING_CONTEXT_COUNT_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) dn == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_dn = new Asn1OctetString(dn);
				
				asn1_dn.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
Пример #10
0
        /// <summary> 
        /// Constructs a new extended operation object for adding a replica to the
        /// specified server.
        /// 
        /// </summary>
        /// <param name="dn">The distinguished name of the replica's partition root.
        /// 
        /// </param>
        /// <param name="serverDN">The server on which the new replica will be added.
        /// 
        /// </param>
        /// <param name="replicaType">The type of replica to add. The replica
        /// types are defined in the ReplicationConstants class.
        /// 
        /// </param>
        /// <param name="flags">Specifies whether all servers in the replica ring must be up
        /// before proceeding. When set to zero, the status of the servers is not
        /// checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be up for the
        /// operation to proceed.
        /// 
        /// </param>
        /// <exception> LdapException A general exception which includes an error message
        /// and an Ldap error code.
        /// 
        /// </exception>
        /// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
        /// </seealso>
        public AddReplicaRequest(System.String dn, System.String serverDN, int replicaType, int flags)
            : base(ReplicationConstants.ADD_REPLICA_REQ, null)
        {
            try
            {

                if (((System.Object) dn == null) || ((System.Object) serverDN == null))
                    throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);

                System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
                LBEREncoder encoder = new LBEREncoder();

                Asn1Integer asn1_flags = new Asn1Integer(flags);
                Asn1Integer asn1_replicaType = new Asn1Integer(replicaType);
                Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
                Asn1OctetString asn1_dn = new Asn1OctetString(dn);

                asn1_flags.encode(encoder, encodedData);
                asn1_replicaType.encode(encoder, encodedData);
                asn1_serverDN.encode(encoder, encodedData);
                asn1_dn.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (System.IO.IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
            }
        }
Пример #11
0
		/// <summary> 
		/// Constructs an extended operations object for reading replica information.
		/// 
		/// </summary>
		/// <param name="serverDN">The server on which the replica resides.
		/// 
		/// </param>
		/// <param name="partitionDN">The distinguished name of the replica to be read.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// </exception>
		public GetReplicaInfoRequest(System.String serverDN, System.String partitionDN):base(ReplicationConstants.GET_REPLICA_INFO_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) serverDN == null) || ((System.Object) partitionDN == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
				Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN);
				
				asn1_serverDN.encode(encoder, encodedData);
				asn1_partitionDN.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
Пример #12
0
        /**
        *
        * Constructs an extended operations object for getting data about any Object.
        *
        * @param objectDN 		The DN of the object to be backed up
        * <br>
        * @param passwd 		The encrypted password required for the object to
        * be backed up
        * <br>
        * @param stateInfo     The state information of the object to backup.
        * This parameter is a String which contains combination of modification
        * timestamp and revision number of object being backed up. The format
        * of both modification time stamp and revision should pertain to eDirectoty
        * standard format of taking modification timestamp and revision.
        * Separator being used between these two is a '+' character.<br>
        *
        *
        * @exception LdapException A general exception which includes an error
        *                          message and an LDAP error code.
        */
        public LdapBackupRequest(String objectDN, byte[] passwd, String stateInfo)
            : base(BackupRestoreConstants.NLDAP_LDAP_BACKUP_REQUEST, null)
        {
            int mts;		// Modifaction time stamp of the Object
            int revision;   // Revision number of the Object
            String mtsStr, revisionStr;

            try
            {
                if (objectDN == null)
                    throw new ArgumentException("PARAM_ERROR");

                //If encrypted password has null reference make it null String
                if(passwd == null)
                    passwd = System.Text.Encoding.UTF8.GetBytes("");

                if (stateInfo == null)
                {
                    // If null reference is passed in stateInfo initialize both
                    // mts and revision
                    mts = 0;
                    revision = 0;
                }
                else
                {
                    // Parse the passed stateInfo to obtain mts and revision
                    stateInfo = stateInfo.Trim();
                    int index = stateInfo.IndexOf('+');
                    if(index == -1)
                        throw new ArgumentException("PARAM_ERROR");
                    mtsStr = stateInfo.Substring(0, index);
                    revisionStr = stateInfo.Substring(index + 1);
                    try
                    {
                        mts = int.Parse(mtsStr);
                    }
                    catch (FormatException e)
                    {
                        throw new LdapLocalException("Invalid Modification Timestamp send in the request", LdapException.ENCODING_ERROR);
                    }
                    try
                    {
                        revision = int.Parse(revisionStr);
                    }
                    catch (FormatException e)
                    {
                        throw new LdapLocalException(
                            "Invalid Revision send in the request",
                            LdapException.ENCODING_ERROR);
                    }
                }

                MemoryStream encodedData = new MemoryStream();
                LBEREncoder encoder = new LBEREncoder();

                // Encode data of objectDN, mts and revision
                Asn1OctetString asn1_objectDN = new Asn1OctetString(objectDN);
                Asn1Integer asn1_mts = new Asn1Integer(mts);
                Asn1Integer asn1_revision = new Asn1Integer(revision);
                Asn1OctetString asn1_passwd = new Asn1OctetString(SupportClass.ToSByteArray(passwd));

                asn1_objectDN.encode(encoder, encodedData);
                asn1_mts.encode(encoder, encodedData);
                asn1_revision.encode(encoder, encodedData);
                asn1_passwd.encode(encoder, encodedData);

                // set the value of operation specific data
                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));

            }
            catch (IOException ioe)
            {
                throw new LdapException("ENCODING_ERROR", LdapException.ENCODING_ERROR, (String) null);
            }
        }
 static LdapPersistSearchControl()
 {
     s_encoder = new LBEREncoder();
     /*
     * This is where we register the control response
     */
     {
         /* Register the Entry Change control class which is returned by the
         * server in response to a persistent search request
         */
         try
         {
             // Register LdapEntryChangeControl
             LdapControl.register(responseOID, System.Type.GetType("Novell.Directory.Ldap.Controls.LdapEntryChangeControl"));
         }
         catch (System.Exception e)
         {
         }
     }
 }
Пример #14
0
        /**
        *
        * Constructs an extended operations object which contains the ber encoded
        * restore data.
        *
        * @param objectDN The object DN to restore
        * <br>
        * @param passwd 		The encrypted password required for the object to
        * be backed up
        * <br>
        * @param bufferLength The length of backed up data
        * <br>
        * @param chunkSizesString The String containing number of chunks and
        * each chunk elements representing chunk sizes
        * <br>
        * @param returnedBuffer The actual data in byte[]
        * <br><br>
        * @exception LdapException A general exception which includes an error
        *                          message and an LDAP error code.
        */
        public LdapRestoreRequest(String objectDN, byte[] passwd, 
            int bufferLength, String chunkSizesString, byte[] returnedBuffer)
            : base(BackupRestoreConstants.NLDAP_LDAP_RESTORE_REQUEST, null)
        {
            try
            {
                //Verify the validity of arguments
                if (objectDN == null || bufferLength == 0 ||
                    chunkSizesString == null || returnedBuffer == null)
                        throw new ArgumentException("PARAM_ERROR");

                //If encrypted password has null reference make it null String
                if(passwd == null)
                    passwd = System.Text.Encoding.UTF8.GetBytes("");

                /*
                 * From the input argument chunkSizesString get::
                 * chunkSize => Represents the number of chunks of data returned from server
                 * sizeOf each chunk => int represents the size of each chunk
                */
                int index;
                int chunkSize;
                int[] chunks = null;
                index = chunkSizesString.IndexOf(';');
                try
                {
                    chunkSize = int.Parse(chunkSizesString.Substring(0, index));
                }
                catch (FormatException e)
                {
                    throw new LdapLocalException(
                            "Invalid data buffer send in the request",
                            LdapException.ENCODING_ERROR);
                }
                //Return exception if chunkSize == 0
                if (chunkSize == 0)
                    throw new ArgumentException("PARAM_ERROR");

                chunkSizesString = chunkSizesString.Substring(index + 1);

                int chunkIndex;
                //Construct chunks array
                chunks = new int[chunkSize];
                /*
                * Iterate through each member in buffer and
                * assign to chunks array elements
                */
                for (int i = 0; i < chunkSize; i++)
                {
                    chunkIndex = chunkSizesString.IndexOf(';');
                    if(chunkIndex == -1)
                    {
                        chunks[i] = int.Parse(chunkSizesString);
                        break;
                    }
                    chunks[i] = int.Parse(chunkSizesString.Substring(0,
                                                            chunkIndex));
                    chunkSizesString = chunkSizesString.Substring(chunkIndex + 1);
                }

                MemoryStream encodedData = new MemoryStream();
                LBEREncoder encoder = new LBEREncoder();

                //Form objectDN, passwd, bufferLength, data byte[] as ASN1 Objects
                Asn1OctetString asn1_objectDN = new Asn1OctetString(objectDN);
                Asn1OctetString asn1_passwd = new Asn1OctetString(SupportClass.ToSByteArray(passwd));
                Asn1Integer asn1_bufferLength = new Asn1Integer(bufferLength);
                Asn1OctetString asn1_buffer = new Asn1OctetString(SupportClass.ToSByteArray(returnedBuffer));

                //Form the chunks sequence to be passed to Server
                Asn1Sequence asn1_chunksSeq = new Asn1Sequence();
                asn1_chunksSeq.add(new Asn1Integer(chunkSize));
                Asn1Set asn1_chunksSet = new Asn1Set();
                for (int i = 0; i < chunkSize; i++)
                {
                    Asn1Integer tmpChunk = new Asn1Integer(chunks[i]);
                    Asn1Sequence tmpSeq = new Asn1Sequence();
                    tmpSeq.add(tmpChunk);
                    asn1_chunksSet.add(tmpSeq);
                }
                asn1_chunksSeq.add(asn1_chunksSet);

                //Encode data to send to server
                asn1_objectDN.encode(encoder, encodedData);
                asn1_passwd.encode(encoder, encodedData);
                asn1_bufferLength.encode(encoder, encodedData);
                asn1_buffer.encode(encoder, encodedData);
                asn1_chunksSeq.encode(encoder, encodedData);

                // set the value of operation specific data
                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));

            }
            catch (IOException ioe)
            {
                throw new LdapException("ENCODING_ERROR", LdapException.ENCODING_ERROR, (String) null);
            }
        }
		/// <summary> Constructs an extended operation object for checking effective rights.
		/// 
		/// </summary>
		/// <param name="dn">       The distinguished name of the entry whose attribute is
		/// being checked.
		/// 
		/// </param>
		/// <param name="trusteeDN">The distinguished name of the entry whose trustee rights
		/// are being returned
		/// 
		/// </param>
		/// <param name="attrName"> The Ldap attribute name.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// </exception>
		
		public GetEffectivePrivilegesRequest(System.String dn, System.String trusteeDN, System.String attrName):base(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_REQ, null)
		{
			
			try
			{
				
				if (((System.Object) dn == null))
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_dn = new Asn1OctetString(dn);
				Asn1OctetString asn1_trusteeDN = new Asn1OctetString(trusteeDN);
				Asn1OctetString asn1_attrName = new Asn1OctetString(attrName);
				
				asn1_dn.encode(encoder, encodedData);
				asn1_trusteeDN.encode(encoder, encodedData);
				asn1_attrName.encode(encoder, encodedData);
				
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}
Пример #16
0
		/// <summary> 
		/// Constructs an extended operations object which contains the ber encoded
		/// replication filter.
		/// 
		/// </summary>
		/// <param name="serverDN">The server whose replication filter needs to be read
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// </exception>
		public GetReplicationFilterRequest(System.String serverDN):base(ReplicationConstants.GET_REPLICATION_FILTER_REQ, null)
		{
			
			try
			{
				
				if ((System.Object) serverDN == null)
					throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
				
				System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
				LBEREncoder encoder = new LBEREncoder();
				
				Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN);
				
				// Add the serverDN to encoded data
				asn1_serverDN.encode(encoder, encodedData);
				setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
			}
			catch (System.IO.IOException ioe)
			{
				throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null);
			}
		}