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.Rfc2251.RfcSearchRequest.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
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.
43 /// SearchRequest ::= [APPLICATION 3] SEQUENCE {
44 /// baseObject LdapDN,
45 /// scope ENUMERATED {
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,
58 /// attributes AttributeDescriptionList }
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)
84 /// <summary> Constructs a new Search Request copying from an existing request.</summary>
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
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
));
114 //*************************************************************************
116 //*************************************************************************
118 /// <summary> Override getIdentifier to return an application-wide id.
121 /// ID = CLASS: APPLICATION, FORM: CONSTRUCTED, TAG: 3. (0x63)
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();