| 1 |
/****************************************************************************** |
| 2 |
* The MIT License |
| 3 |
* Copyright (c) 2003 Novell Inc. www.novell.com |
| 4 |
* |
| 5 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
* of this software and associated documentation files (the Software), to deal |
| 7 |
* in the Software without restriction, including without limitation the rights |
| 8 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
* copies of the Software, and to permit persons to whom the Software is |
| 10 |
* furnished to do so, subject to the following conditions: |
| 11 |
* |
| 12 |
* The above copyright notice and this permission notice shall be included in |
| 13 |
* all copies or substantial portions of the Software. |
| 14 |
* |
| 15 |
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
* SOFTWARE. |
| 22 |
*******************************************************************************/ |
| 23 |
// |
| 24 |
// Novell.Directory.Ldap.Extensions.GetReplicaInfoRequest.cs |
| 25 |
// |
| 26 |
// Author: |
| 27 |
// Sunil Kumar ([email protected]) |
| 28 |
// |
| 29 |
// (C) 2003 Novell, Inc (http://www.novell.com) |
| 30 |
// |
| 31 |
|
| 32 |
using System; |
| 33 |
using Novell.Directory.Ldap; |
| 34 |
using Novell.Directory.Ldap.Asn1; |
| 35 |
using Novell.Directory.Ldap.Utilclass; |
| 36 |
|
| 37 |
namespace Novell.Directory.Ldap.Extensions |
| 38 |
{ |
| 39 |
|
| 40 |
/// <summary> |
| 41 |
/// Reads information about a replica. |
| 42 |
/// |
| 43 |
/// The information available includes such items as replicas state, last |
| 44 |
/// modification time, and replica type. |
| 45 |
/// |
| 46 |
/// To read other information about a replica, you must |
| 47 |
/// create an instance of this class and then call the |
| 48 |
/// extendedOperation method with this object as the required |
| 49 |
/// LdapExtendedOperation parameter. |
| 50 |
/// |
| 51 |
/// The getReplicaInfoRequest extension uses the following OID: |
| 52 |
/// 2.16.840.1.113719.1.27.100.17 |
| 53 |
/// |
| 54 |
/// The requestValue has the following format: |
| 55 |
/// |
| 56 |
/// requestValue ::= |
| 57 |
/// serverDN LdapDN |
| 58 |
/// partitionDN LdapDN |
| 59 |
/// </summary> |
| 60 |
public class GetReplicaInfoRequest:LdapExtendedOperation |
| 61 |
{ |
| 62 |
|
| 63 |
static GetReplicaInfoRequest() |
| 64 |
{ |
| 65 |
/* |
| 66 |
* Register the extendedresponse class which is returned by the |
| 67 |
* server in response to a ListReplicasRequest |
| 68 |
*/ |
| 69 |
try |
| 70 |
{ |
| 71 |
LdapExtendedResponse.register(ReplicationConstants.GET_REPLICA_INFO_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetReplicaInfoResponse")); |
| 72 |
} |
| 73 |
catch (System.Exception e) |
| 74 |
{ |
| 75 |
System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found"); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
/// <summary> |
| 80 |
/// Constructs an extended operations object for reading replica information. |
| 81 |
/// |
| 82 |
/// </summary> |
| 83 |
/// <param name="serverDN">The server on which the replica resides. |
| 84 |
/// |
| 85 |
/// </param> |
| 86 |
/// <param name="partitionDN">The distinguished name of the replica to be read. |
| 87 |
/// |
| 88 |
/// </param> |
| 89 |
/// <exception> LdapException A general exception which includes an error |
| 90 |
/// message and an Ldap error code. |
| 91 |
/// </exception> |
| 92 |
public GetReplicaInfoRequest(System.String serverDN, System.String partitionDN):base(ReplicationConstants.GET_REPLICA_INFO_REQ, null) |
| 93 |
{ |
| 94 |
|
| 95 |
try |
| 96 |
{ |
| 97 |
|
| 98 |
if (((System.Object) serverDN == null) || ((System.Object) partitionDN == null)) |
| 99 |
throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR); |
| 100 |
|
| 101 |
System.IO.MemoryStream encodedData = new System.IO.MemoryStream(); |
| 102 |
LBEREncoder encoder = new LBEREncoder(); |
| 103 |
|
| 104 |
Asn1OctetString asn1_serverDN = new Asn1OctetString(serverDN); |
| 105 |
Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN); |
| 106 |
|
| 107 |
asn1_serverDN.encode(encoder, encodedData); |
| 108 |
asn1_partitionDN.encode(encoder, encodedData); |
| 109 |
|
| 110 |
setValue(SupportClass.ToSByteArray(encodedData.ToArray())); |
| 111 |
} |
| 112 |
catch (System.IO.IOException ioe) |
| 113 |
{ |
| 114 |
throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String) null); |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
} |