Ejemplo n.º 1
0
        /// <summary> Constructs an object from the responseValue which contains the effective
        /// privileges.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///   privileges  INTEGER
        ///
        /// </summary>
        /// <exception> IOException The responseValue could not be decoded.
        /// </exception>
        public GetEffectivePrivilegesResponse(RfcLdapMessage rfcMessage) : base(rfcMessage)
        {
            if (ResultCode == LdapException.SUCCESS)
            {
                // parse the contents of the reply
                sbyte[] returnedValue = Value;
                if (returnedValue == null)
                {
                    throw new System.IO.IOException("No returned value");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();
                if (decoder == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                Asn1Integer asn1_privileges = (Asn1Integer)decoder.decode(returnedValue);
                if (asn1_privileges == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                privileges = asn1_privileges.intValue();
            }
            else
            {
                privileges = 0;
            }
        }
Ejemplo n.º 2
0
        /// <summary> Constructs an object from the responseValue which contains the
        /// entry count.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///   count  INTEGER
        ///
        /// </summary>
        /// <exception> IOException  The response value could not be decoded.
        /// </exception>
        public PartitionEntryCountResponse(RfcLdapMessage rfcMessage) : base(rfcMessage)
        {
            if (ResultCode == LdapException.SUCCESS)
            {
                // parse the contents of the reply
                sbyte[] returnedValue = Value;
                if (returnedValue == null)
                {
                    throw new System.IO.IOException("No returned value");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();
                if (decoder == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                Asn1Integer asn1_count = (Asn1Integer)decoder.decode(returnedValue);
                if (asn1_count == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                count = asn1_count.intValue();
            }
            else
            {
                count = -1;
            }
        }
Ejemplo n.º 3
0
        /// <summary> Constructs an object from the responseValue which contains the
        /// replica information.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///  partitionID         INTEGER
        ///  replicaState        INTEGER
        ///  modificationTime    INTEGER
        ///  purgeTime           INTEGER
        ///  localPartitionID    INTEGER
        ///  partitionDN       OCTET STRING
        ///  replicaType         INTEGER
        ///  flags               INTEGER
        ///
        /// </summary>
        /// <exception> IOException The response value could not be decoded.
        /// </exception>
        public GetReplicaInfoResponse(RfcLdapMessage rfcMessage) : base(rfcMessage)
        {
            if (ResultCode == LdapException.SUCCESS)
            {
                // parse the contents of the reply
                sbyte[] returnedValue = Value;
                if (returnedValue == null)
                {
                    throw new System.IO.IOException("No returned value");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();
                if (decoder == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                // Parse the parameters in the order

                System.IO.MemoryStream currentPtr = new System.IO.MemoryStream(SupportClass.ToByteArray(returnedValue));

                // Parse partitionID
                Asn1Integer asn1_partitionID = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_partitionID == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                partitionID = asn1_partitionID.intValue();


                // Parse replicaState
                Asn1Integer asn1_replicaState = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_replicaState == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                replicaState = asn1_replicaState.intValue();

                // Parse modificationTime
                Asn1Integer asn1_modificationTime = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_modificationTime == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                modificationTime = asn1_modificationTime.intValue();

                // Parse purgeTime
                Asn1Integer asn1_purgeTime = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_purgeTime == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                purgeTime = asn1_purgeTime.intValue();

                // Parse localPartitionID
                Asn1Integer asn1_localPartitionID = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_localPartitionID == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                localPartitionID = asn1_localPartitionID.intValue();

                // Parse partitionDN
                Asn1OctetString asn1_partitionDN = (Asn1OctetString)decoder.decode(currentPtr);
                if (asn1_partitionDN == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                partitionDN = asn1_partitionDN.stringValue();
                if ((object)partitionDN == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }


                // Parse replicaType
                Asn1Integer asn1_replicaType = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_replicaType == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                replicaType = asn1_replicaType.intValue();


                // Parse flags
                Asn1Integer asn1_flags = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_flags == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                flags = asn1_flags.intValue();
            }
            else
            {
                partitionID      = 0;
                replicaState     = 0;
                modificationTime = 0;
                purgeTime        = 0;
                localPartitionID = 0;
                partitionDN      = "";
                replicaType      = 0;
                flags            = 0;
            }
        }
Ejemplo n.º 4
0
        /**
         * Constructs an object from the responseValue which contains the backup data.
         *  <p>The constructor parses the responseValue which has the following
         *  format:<br>
         *  responseValue ::=<br>
         *  <p>databufferLength ::= INTEGER <br>
         *  mts(modification time stamp) ::= INTEGER<br>
         *  revision ::= INTEGER<br>
         *  returnedBuffer ::= OCTET STRING<br>
         *  dataChunkSizes ::= <br>
         *  SEQUENCE{<br>
         *  noOfChunks INTEGER<br>
         *  SET of [<br>
         *  SEQUENCE of {eachChunksize INTEGER}]<br>
         *  }</p>
         *
         * @exception IOException The responseValue could not be decoded.
         */

        public LdapBackupResponse(RfcLdapMessage rfcMessage) : base(rfcMessage)
        {
            int modificationTime = 0;     // Modifaction timestamp of the Object
            int revision         = 0;     // Revision number of the Object
            int chunksSize       = 0;

            int[] chunks = null;             //Holds size of each chunks returned from server

            //Verify if returned ID is not proper
            if (ID == null || !(ID.Equals(BackupRestoreConstants.NLDAP_LDAP_BACKUP_RESPONSE)))
            {
                throw new IOException("LDAP Extended Operation not supported");
            }

            if (ResultCode == LdapException.SUCCESS)
            {
                // Get the contents of the reply

                byte[] returnedValue = SupportClass.ToByteArray(Value);
                if (returnedValue == null)
                {
                    throw new Exception("LDAP Operations error. No returned value.");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();

                if (decoder == null)
                {
                    throw new Exception("Decoding error");
                }

                // Parse the parameters in the order
                MemoryStream currentPtr = new MemoryStream(returnedValue);

                // Parse bufferLength
                Asn1Integer asn1_bufferLength = (Asn1Integer)decoder
                                                .decode(currentPtr);
                if (asn1_bufferLength == null)
                {
                    throw new IOException("Decoding error");
                }
                bufferLength = asn1_bufferLength.intValue();

                // Parse modificationTime
                Asn1Integer asn1_modificationTime = (Asn1Integer)decoder
                                                    .decode(currentPtr);
                if (asn1_modificationTime == null)
                {
                    throw new IOException("Decoding error");
                }
                modificationTime = asn1_modificationTime.intValue();

                // Parse revision
                Asn1Integer asn1_revision = (Asn1Integer)decoder
                                            .decode(currentPtr);
                if (asn1_revision == null)
                {
                    throw new IOException("Decoding error");
                }
                revision = asn1_revision.intValue();

                //Format stateInfo to contain both modificationTime and revision
                stateInfo = modificationTime + "+" + revision;

                // Parse returnedBuffer
                Asn1OctetString asn1_returnedBuffer = (Asn1OctetString)decoder.decode(currentPtr);
                if (asn1_returnedBuffer == null)
                {
                    throw new IOException("Decoding error");
                }

                returnedBuffer = SupportClass.ToByteArray(asn1_returnedBuffer.byteValue());


                /*
                 * Parse chunks array
                 * Chunks returned from server is encoded as shown below::
                 * SEQUENCE{
                 *          chunksSize	INTEGER
                 *          SET of [
                 *              SEQUENCE of {eacChunksize        INTEGER}]
                 *         }
                 */

                Asn1Sequence asn1_chunksSeq = (Asn1Sequence)decoder
                                              .decode(currentPtr);
                if (asn1_chunksSeq == null)
                {
                    throw new IOException("Decoding error");
                }

                //Get number of chunks returned from server
                chunksSize = ((Asn1Integer)asn1_chunksSeq.get_Renamed(0)).intValue();

                //Construct chunks array
                chunks = new int[chunksSize];

                Asn1Set asn1_chunksSet = (Asn1Set)asn1_chunksSeq.get_Renamed(1);
                //Iterate through asn1_chunksSet and put each size into chunks array

                for (int index = 0; index < chunksSize; index++)
                {
                    Asn1Sequence asn1_eachSeq = (Asn1Sequence)asn1_chunksSet.get_Renamed(index);
                    chunks[index] = ((Asn1Integer)asn1_eachSeq.get_Renamed(0)).intValue();
                }

                //Construct a temporary StringBuffer and append chunksSize, each size
                //element in chunks array and actual data of eDirectoty Object
                System.Text.StringBuilder tempBuffer = new System.Text.StringBuilder();
                tempBuffer.Append(chunksSize);
                tempBuffer.Append(";");
                int i = 0;

                for (; i < (chunksSize - 1); i++)
                {
                    tempBuffer.Append(chunks[i]);
                    tempBuffer.Append(";");
                }

                tempBuffer.Append(chunks[i]);

                //Assign tempBuffer to parsedString to be returned to Application
                chunkSizesString = tempBuffer.ToString();
            }
            else
            {
                //Intialize all these if getResultCode() != LdapException.SUCCESS
                bufferLength     = 0;
                stateInfo        = null;
                chunkSizesString = null;
                returnedBuffer   = null;
            }
        }