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.RfcLdapResult.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 using Novell.Directory.Ldap.Asn1;
35 namespace Novell.Directory.Ldap.Rfc2251
38 /// <summary> Represents an LdapResult.
41 /// LdapResult ::= SEQUENCE {
42 /// resultCode ENUMERATED {
44 /// operationsError (1),
45 /// protocolError (2),
46 /// timeLimitExceeded (3),
47 /// sizeLimitExceeded (4),
50 /// authMethodNotSupported (7),
51 /// strongAuthRequired (8),
53 /// referral (10), -- new
54 /// adminLimitExceeded (11), -- new
55 /// unavailableCriticalExtension (12), -- new
56 /// confidentialityRequired (13), -- new
57 /// saslBindInProgress (14), -- new
58 /// noSuchAttribute (16),
59 /// undefinedAttributeType (17),
60 /// inappropriateMatching (18),
61 /// constraintViolation (19),
62 /// attributeOrValueExists (20),
63 /// invalidAttributeSyntax (21),
64 /// -- 22-31 unused --
65 /// noSuchObject (32),
66 /// aliasProblem (33),
67 /// invalidDNSyntax (34),
68 /// -- 35 reserved for undefined isLeaf --
69 /// aliasDereferencingProblem (36),
70 /// -- 37-47 unused --
71 /// inappropriateAuthentication (48),
73 /// invalidCredentials (49),
74 /// insufficientAccessRights (50),
77 /// unwillingToPerform (53),
79 /// -- 55-63 unused --
80 /// namingViolation (64),
81 /// objectClassViolation (65),
82 /// notAllowedOnNonLeaf (66),
83 /// notAllowedOnRDN (67),
84 /// entryAlreadyExists (68),
85 /// objectClassModsProhibited (69),
86 /// -- 70 reserved for CLdap --
87 /// affectsMultipleDSAs (71), -- new
88 /// -- 72-79 unused --
90 /// -- 81-90 reserved for APIs --
92 /// errorMessage LdapString,
93 /// referral [3] Referral OPTIONAL }
97 public class RfcLdapResult:Asn1Sequence, RfcResponse
100 /// <summary> Context-specific TAG for optional Referral.</summary>
101 public const int REFERRAL = 3;
103 //*************************************************************************
104 // Constructors for RfcLdapResult
105 //*************************************************************************
107 /// <summary> Constructs an RfcLdapResult from parameters
110 /// <param name="resultCode">the result code of the operation
113 /// <param name="matchedDN">the matched DN returned from the server
116 /// <param name="errorMessage">the diagnostic message returned from the server
118 public RfcLdapResult(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage):this(resultCode, matchedDN, errorMessage, null)
123 /// <summary> Constructs an RfcLdapResult from parameters
126 /// <param name="resultCode">the result code of the operation
129 /// <param name="matchedDN">the matched DN returned from the server
132 /// <param name="errorMessage">the diagnostic message returned from the server
135 /// <param name="referral">the referral(s) returned by the server
137 public RfcLdapResult(Asn1Enumerated resultCode, RfcLdapDN matchedDN, RfcLdapString errorMessage, RfcReferral referral):base(4)
142 if (referral != null)
147 /// <summary> Constructs an RfcLdapResult from the inputstream</summary>
148 [CLSCompliantAttribute(false)]
149 public RfcLdapResult(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(dec, in_Renamed, len)
152 // Decode optional referral from Asn1OctetString to Referral.
155 Asn1Tagged obj = (Asn1Tagged) get_Renamed(3);
156 Asn1Identifier id = obj.getIdentifier();
157 if (id.Tag == RfcLdapResult.REFERRAL)
159 sbyte[] content = ((Asn1OctetString) obj.taggedValue()).byteValue();
160 System.IO.MemoryStream bais = new System.IO.MemoryStream(SupportClass.ToByteArray(content));
161 set_Renamed(3, new RfcReferral(dec, bais, content.Length));
167 //*************************************************************************
169 //*************************************************************************
171 /// <summary> Returns the result code from the server
174 /// <returns> the result code
176 public Asn1Enumerated getResultCode()
178 return (Asn1Enumerated) get_Renamed(0);
181 /// <summary> Returns the matched DN from the server
184 /// <returns> the matched DN
186 public RfcLdapDN getMatchedDN()
188 return new RfcLdapDN(((Asn1OctetString) get_Renamed(1)).byteValue());
191 /// <summary> Returns the error message from the server
194 /// <returns> the server error message
196 public RfcLdapString getErrorMessage()
198 return new RfcLdapString(((Asn1OctetString) get_Renamed(2)).byteValue());
201 /// <summary> Returns the referral(s) from the server
204 /// <returns> the referral(s)
206 public RfcReferral getReferral()
208 return (size() > 3)?(RfcReferral) get_Renamed(3):null;