1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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
22 *******************************************************************************/
24 // Novell.Directory.Ldap.LdapExtendedRequest.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 using Asn1OctetString = Novell.Directory.Ldap.Asn1.Asn1OctetString;
34 using Asn1Tagged = Novell.Directory.Ldap.Asn1.Asn1Tagged;
35 using RfcExtendedRequest = Novell.Directory.Ldap.Rfc2251.RfcExtendedRequest;
36 using RfcLdapOID = Novell.Directory.Ldap.Rfc2251.RfcLdapOID;
38 namespace Novell.Directory.Ldap
41 /// <summary> Represents an Ldap Extended Request.
44 /// <seealso cref="LdapConnection.SendRequest">
47 * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
48 * requestName [0] LdapOID,
49 * requestValue [1] OCTET STRING OPTIONAL }
51 public class LdapExtendedRequest:LdapMessage
53 /// <summary> Retrieves an extended operation from this request</summary>
54 /// <returns> extended operation represented in this request.
56 virtual public LdapExtendedOperation ExtendedOperation
60 RfcExtendedRequest xreq = (RfcExtendedRequest) this.Asn1Object.get_Renamed(1);
62 //Zeroth element is the OID, element one is the value
63 Asn1Tagged tag = (Asn1Tagged) xreq.get_Renamed(0);
64 RfcLdapOID oid = (RfcLdapOID) tag.taggedValue();
65 System.String requestID = oid.stringValue();
67 sbyte[] requestValue = null;
70 tag = (Asn1Tagged) xreq.get_Renamed(1);
71 Asn1OctetString value_Renamed = (Asn1OctetString) tag.taggedValue();
72 requestValue = value_Renamed.byteValue();
74 return new LdapExtendedOperation(requestID, requestValue);
78 /// <summary> Constructs an LdapExtendedRequest.
81 /// <param name="op"> The object which contains (1) an identifier of an extended
82 /// operation which should be recognized by the particular Ldap
83 /// server this client is connected to, and (2) an operation-
84 /// specific sequence of octet strings or BER-encoded values.
87 /// <param name="cont">Any controls that apply to the extended request
90 public LdapExtendedRequest(LdapExtendedOperation op, LdapControl[] cont):base(LdapMessage.EXTENDED_REQUEST, new RfcExtendedRequest(new RfcLdapOID(op.getID()), (op.getValue() != null)?new Asn1OctetString(op.getValue()):null), cont)