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.Controls.LdapSortResponse.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 using Novell.Directory.Ldap;
\r
34 using Novell.Directory.Ldap.Asn1;
\r
36 namespace Novell.Directory.Ldap.Controls
\r
39 /// <summary> LdapSortResponse - will be added in newer version of Ldap
\r
40 /// Controls draft-- add descritption from draft here.
\r
42 public class LdapSortResponse:LdapControl
\r
44 /// <summary> If not null, this returns the attribute that caused the sort
\r
45 /// operation to fail.
\r
47 virtual public System.String FailedAttribute
\r
51 return failedAttribute;
\r
55 /// <summary> Returns the result code from the sort</summary>
\r
56 virtual public int ResultCode
\r
65 private System.String failedAttribute;
\r
66 private int resultCode;
\r
68 /// <summary> This constructor is usually called by the SDK to instantiate an
\r
69 /// a LdapControl corresponding to the Server response to a Ldap
\r
70 /// Sort Control request. Application programmers should not have
\r
71 /// any reason to call the constructor. This constructor besides
\r
72 /// constructing a LdapControl object parses the contents of the response
\r
75 /// RFC 2891 defines this response control as follows:
\r
77 /// The controlValue is an OCTET STRING, whose
\r
78 /// value is the BER encoding of a value of the following SEQUENCE:
\r
79 /// SortResult ::= SEQUENCE {
\r
80 /// sortResult ENUMERATED {
\r
81 /// success (0), -- results are sorted
\r
82 /// operationsError (1), -- server internal failure
\r
83 /// timeLimitExceeded (3), -- timelimit reached before
\r
84 /// -- sorting was completed
\r
85 /// strongAuthRequired (8), -- refused to return sorted
\r
86 /// -- results via insecure
\r
88 /// adminLimitExceeded (11), -- too many matching entries
\r
89 /// -- for the server to sort
\r
90 /// noSuchAttribute (16), -- unrecognized attribute
\r
91 /// -- type in sort key
\r
92 /// inappropriateMatching (18), -- unrecognized or
\r
93 /// -- inappropriate matching
\r
94 /// -- rule in sort key
\r
95 /// insufficientAccessRights (50), -- refused to return sorted
\r
96 /// -- results to this client
\r
97 /// busy (51), -- too busy to process
\r
98 /// unwillingToPerform (53), -- unable to sort
\r
101 /// attributeType [0] AttributeDescription OPTIONAL }
\r
105 /// <param name="oid"> The OID of the control, as a dotted string.
\r
108 /// <param name="critical"> True if the Ldap operation should be discarded if
\r
109 /// the control is not supported. False if
\r
110 /// the operation can be processed without the control.
\r
113 /// <param name="values"> The control-specific data.
\r
115 [CLSCompliantAttribute(false)]
\r
116 public LdapSortResponse(System.String oid, bool critical, sbyte[] values):base(oid, critical, values)
\r
119 // Create a decoder object
\r
120 LBERDecoder decoder = new LBERDecoder();
\r
121 if (decoder == null)
\r
122 throw new System.IO.IOException("Decoding error");
\r
124 // We should get back an enumerated type
\r
125 Asn1Object asnObj = decoder.decode(values);
\r
127 if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
\r
128 throw new System.IO.IOException("Decoding error");
\r
131 Asn1Object asn1Enum = ((Asn1Sequence) asnObj).get_Renamed(0);
\r
132 if ((asn1Enum != null) && (asn1Enum is Asn1Enumerated))
\r
133 resultCode = ((Asn1Enumerated) asn1Enum).intValue();
\r
135 // Second element is the attributeType
\r
136 if (((Asn1Sequence) asnObj).size() > 1)
\r
138 Asn1Object asn1String = ((Asn1Sequence) asnObj).get_Renamed(1);
\r
139 if ((asn1String != null) && (asn1String is Asn1OctetString))
\r
140 failedAttribute = ((Asn1OctetString) asn1String).stringValue();
\r