コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Constructs an extended operation object for sending updates to a replica ring.
        ///
        /// </summary>
        /// <param name="partitionRoot">The distinguished name of the replica
        /// that will be updated.
        ///
        /// </param>
        /// <param name="origServerDN"> The distinguished name of the server that sends the
        /// updates to the replica ring.
        ///
        /// </param>
        /// <exception> LdapException A general exception which includes an error message
        /// and an Ldap error code.
        /// </exception>
        public SendAllUpdatesRequest(string partitionRoot, string origServerDN)
            : base(ReplicationConstants.SEND_ALL_UPDATES_REQ, null)
        {
            try
            {
                if (partitionRoot == null || origServerDN == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }
                MemoryStream encodedData = new MemoryStream();
                LBEREncoder  encoder     = new LBEREncoder();

                Asn1OctetString asn1_partitionRoot = new Asn1OctetString(partitionRoot);
                Asn1OctetString asn1_origServerDN  = new Asn1OctetString(origServerDN);

                asn1_partitionRoot.encode(encoder, encodedData);
                asn1_origServerDN.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null);
            }
        }
コード例 #3
0
        /// <summary> Constructs an extended operation object for merging partitions.
        ///
        /// </summary>
        /// <param name="dn">       The distinguished name of the child partition's 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 MergePartitionsRequest(System.String dn, int flags) : base(ReplicationConstants.MERGE_NAMING_CONTEXT_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();

                Asn1Integer     asn1_flags = new Asn1Integer(flags);
                Asn1OctetString asn1_dn    = new Asn1OctetString(dn);

                asn1_flags.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);
            }
        }
コード例 #4
0
ファイル: GetReplicaInfoRequest.cs プロジェクト: cmsd2/oidc
        /// <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(String serverDN, String partitionDN) : base(ReplicationConstants.GET_REPLICA_INFO_REQ, null)
        {
            try
            {
                if (((object)serverDN == null) || ((object)partitionDN == null))
                {
                    throw new 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, (String)null);
            }
        }
コード例 #5
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(string partitionRoot, string toServerDN, string fromServerDN)
            : base(ReplicationConstants.RECEIVE_ALL_UPDATES_REQ, null)
        {
            try
            {
                if ((object)partitionRoot == null || (object)toServerDN == null || (object)fromServerDN == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                var asn1_partitionRoot = new Asn1OctetString(partitionRoot);
                var asn1_toServerDN    = new Asn1OctetString(toServerDN);
                var 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 (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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(string serverName, string partitionRoot, int delay)
            : base(ReplicationConstants.NAMING_CONTEXT_SYNC_REQ, null)
        {
            try
            {
                if ((object)serverName == null || (object)partitionRoot == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                var asn1_serverName    = new Asn1OctetString(serverName);
                var asn1_partitionRoot = new Asn1OctetString(partitionRoot);
                var 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 (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
コード例 #8
0
ファイル: SchemaSyncRequest.cs プロジェクト: cmsd2/oidc
        /// <summary>  Constructs an extended operation object for synchronizing the schema.
        ///
        /// </summary>
        /// <param name="serverName">    The distinguished name of the server which will start
        /// the synchronization.
        ///
        /// </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 SchemaSyncRequest(String serverName, int delay) : base(ReplicationConstants.SCHEMA_SYNC_REQ, null)
        {
            try
            {
                if ((object)serverName == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);
                Asn1Integer     asn1_delay      = new Asn1Integer(delay);

                asn1_serverName.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, (String)null);
            }
        }
コード例 #9
0
        /// <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={"attr1","attr2",...,null}> The Ldap attribute names list.
        ///
        /// </param>
        /// <exception> LdapException A general exception which includes an error
        /// message and an Ldap error code.
        /// </exception>

        public GetEffectivePrivilegesListRequest(String dn, String trusteeDN, String[] attrName) : base(ReplicationConstants.GET_EFFECTIVE_LIST_PRIVILEGES_REQ, null)
        {
            try
            {
                if (((object)dn == null))
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                Asn1OctetString asn1_trusteeDN = new Asn1OctetString(trusteeDN);
                Asn1OctetString asn1_dn        = new Asn1OctetString(dn);
                asn1_trusteeDN.encode(encoder, encodedData);
                asn1_dn.encode(encoder, encodedData);

                Asn1Sequence asn1_seqattr = new Asn1Sequence();
                for (int i = 0; attrName[i] != null; i++)
                {
                    Asn1OctetString asn1_attrName = new Asn1OctetString(attrName[i]);
                    asn1_seqattr.add(asn1_attrName);
                }
                asn1_seqattr.encode(encoder, encodedData);
                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (String)null);
            }
        }
コード例 #10
0
        /// <summary>
        ///     Constructs an extended operation object for deleting an orphan partition.
        /// </summary>
        /// <param name="serverDN">
        ///     The distinguished name of the server
        ///     on which the orphan partition resides.
        /// </param>
        /// <param name="contextName">
        ///     The distinguished name of the orphan
        ///     partition to delete.
        /// </param>
        /// <exception>
        ///     LdapException A general exception which includes an error message
        ///     and an Ldap error code.
        /// </exception>
        public RemoveOrphanPartitionRequest(string serverDN, string contextName)
            : base(ReplicationConstants.REMOVE_ORPHAN_NAMING_CONTEXT_REQ, null)
        {
            try
            {
                if ((object)serverDN == null || (object)contextName == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                var asn1_serverDN    = new Asn1OctetString(serverDN);
                var asn1_contextName = new Asn1OctetString(contextName);

                asn1_serverDN.encode(encoder, encodedData);
                asn1_contextName.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
コード例 #11
0
        /// <summary>
        ///     Constructs an extended operation object for splitting partition.
        /// </summary>
        /// <param name="dn">
        ///     The distinguished name of the container where the new
        ///     partition  root should be located.
        /// </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>
        public SplitPartitionRequest(string dn, int flags) : base(ReplicationConstants.CREATE_NAMING_CONTEXT_REQ, null)
        {
            try
            {
                if ((object)dn == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                var asn1_flags = new Asn1Integer(flags);
                var asn1_dn    = new Asn1OctetString(dn);

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

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
コード例 #12
0
        /// <summary>
        /// Constructs a new extended operation object for changing a replica's type.
        ///
        /// </summary>
        /// <param name="dn">         The distinguished name of the replica's
        /// partition root.
        ///
        /// </param>
        /// <param name="serverDN">   The server on which the replica resides.
        ///
        ///
        /// </param>
        /// <param name="replicaType">   The new replica type. 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 ChangeReplicaTypeRequest(string dn, string serverDN, int replicaType, int flags)
            : base(ReplicationConstants.CHANGE_REPLICA_TYPE_REQ, null)
        {
            try
            {
                if (dn == null || serverDN == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

                MemoryStream encodedData = new 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 (IOException)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null);
            }
        }
コード例 #13
0
        /// <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(String partitionDN, int flags) : base(ReplicationConstants.ABORT_NAMING_CONTEXT_OP_REQ, null)
        {
            try
            {
                if ((object)partitionDN == null)
                {
                    throw new 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, (String)null);
            }
        }
コード例 #14
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);
            }
        }
コード例 #15
0
        /// <summary>
        ///     Constructs an extended operation object for removing a replica.
        /// </summary>
        /// <param name="dn">
        ///     The distinguished name of the replica's
        ///     partition root.
        /// </param>
        /// <param name="serverDN">
        ///     The distinguished name of server from which the replica
        ///     will be removed.
        /// </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 RemoveReplicaRequest(string dn, string serverDN, int flags)
            : base(ReplicationConstants.DELETE_REPLICA_REQ, null)
        {
            try
            {
                if ((object)dn == null || (object)serverDN == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

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

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

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
コード例 #16
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(string serverName)
            : base(ReplicationConstants.LIST_REPLICAS_REQ, null)
        {
            try
            {
                if (serverName == null)
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);

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

                Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);

                asn1_serverName.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null);
            }
        }
        /// <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);
            }
        }
コード例 #18
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(String dn) : base(ReplicationConstants.NAMING_CONTEXT_COUNT_REQ, null)
        {
            try
            {
                if (((object)dn == null))
                {
                    throw new 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, (String)null);
            }
        }
コード例 #19
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);
            }
        }
コード例 #20
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);
            }
        }
コード例 #21
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);
            }
        }