public encode ( Asn1Encoder enc, System out_Renamed ) : void | ||
enc | Asn1Encoder | Encoder object to use when encoding self. /// /// |
out_Renamed | System | |
return | void |
/// <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(System.String serverName, int delay):base(ReplicationConstants.SCHEMA_SYNC_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); 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, (System.String) null); } }
/// <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(System.String dn, int flags) : base(ReplicationConstants.CREATE_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); } }
/// <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); } }
/** * * 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); } }
/** * * 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); } }