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