**** Merged from MCS ****
[mono-project.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap.Rfc2251 / RfcSearchRequest.cs
blobb67be6f75e3a34362ef78e418a8a263edaad45fb
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:
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
21 * SOFTWARE.
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Rfc2251.RfcSearchRequest.cs
26 // Author:
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
32 using System;
33 using LdapException = Novell.Directory.Ldap.LdapException;
34 using Novell.Directory.Ldap;
35 using Novell.Directory.Ldap.Asn1;
37 namespace Novell.Directory.Ldap.Rfc2251
40 /// <summary> Represents an Ldap Search Request.
41 ///
42 /// <pre>
43 /// SearchRequest ::= [APPLICATION 3] SEQUENCE {
44 /// baseObject LdapDN,
45 /// scope ENUMERATED {
46 /// baseObject (0),
47 /// singleLevel (1),
48 /// wholeSubtree (2) },
49 /// derefAliases ENUMERATED {
50 /// neverDerefAliases (0),
51 /// derefInSearching (1),
52 /// derefFindingBaseObj (2),
53 /// derefAlways (3) },
54 /// sizeLimit INTEGER (0 .. maxInt),
55 /// timeLimit INTEGER (0 .. maxInt),
56 /// typesOnly BOOLEAN,
57 /// filter Filter,
58 /// attributes AttributeDescriptionList }
59 /// </pre>
60 /// </summary>
61 public class RfcSearchRequest:Asn1Sequence, RfcRequest
64 //*************************************************************************
65 // Constructors for SearchRequest
66 //*************************************************************************
71 public RfcSearchRequest(RfcLdapDN baseObject, Asn1Enumerated scope, Asn1Enumerated derefAliases, Asn1Integer sizeLimit, Asn1Integer timeLimit, Asn1Boolean typesOnly, RfcFilter filter, RfcAttributeDescriptionList attributes):base(8)
73 add(baseObject);
74 add(scope);
75 add(derefAliases);
76 add(sizeLimit);
77 add(timeLimit);
78 add(typesOnly);
79 add(filter);
80 add(attributes);
81 return ;
84 /// <summary> Constructs a new Search Request copying from an existing request.</summary>
85 /* package */
86 internal RfcSearchRequest(Asn1Object[] origRequest, System.String base_Renamed, System.String filter, bool request):base(origRequest, origRequest.Length)
89 // Replace the base if specified, otherwise keep original base
90 if ((System.Object) base_Renamed != null)
92 set_Renamed(0, new RfcLdapDN(base_Renamed));
95 // If this is a reencode of a search continuation reference
96 // and if original scope was one-level, we need to change the scope to
97 // base so we don't return objects a level deeper than requested
98 if (request)
100 int scope = ((Asn1Enumerated) origRequest[1]).intValue();
101 if (scope == LdapConnection.SCOPE_ONE)
103 set_Renamed(1, new Asn1Enumerated(LdapConnection.SCOPE_BASE));
106 // Replace the filter if specified, otherwise keep original filter
107 if ((System.Object) filter != null)
109 set_Renamed(6, new RfcFilter(filter));
111 return ;
114 //*************************************************************************
115 // Accessors
116 //*************************************************************************
118 /// <summary> Override getIdentifier to return an application-wide id.
119 ///
120 /// <pre>
121 /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 3. (0x63)
122 /// </pre>
123 /// </summary>
124 public override Asn1Identifier getIdentifier()
126 return new Asn1Identifier(Asn1Identifier.APPLICATION, true, LdapMessage.SEARCH_REQUEST);
129 public RfcRequest dupRequest(System.String base_Renamed, System.String filter, bool request)
131 return new RfcSearchRequest(toArray(), base_Renamed, filter, request);
134 public System.String getRequestDN()
136 return ((RfcLdapDN) get_Renamed(0)).stringValue();