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.LdapException.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 using Novell.Directory.Ldap.Utilclass;
35 namespace Novell.Directory.Ldap
38 /// <summary> Thrown to indicate that an Ldap exception has occurred. This is a general
39 /// exception which includes a message and an Ldap result code.
41 /// An LdapException can result from physical problems (such as
42 /// network errors) as well as problems with Ldap operations detected
43 /// by the server. For example, if an Ldap add operation fails because of a
44 /// duplicate entry, the server returns a result code.
46 /// Five possible sources of information are available from LdapException:
48 /// <dt>Result Code:</dt>
49 /// <dd>The <code>getResultCode</code> method returns a result code,
50 /// which can be compared against standard Ldap result codes. </dd>
52 /// <dd>The <code>getMessage</code> method returns a localized message
53 /// from the message resource that corresponds to the result code.
55 /// <dt>Ldap server Message:</dt>
56 /// <dd>The <code>getLdapErrorMessage</code> method returns any error
57 /// message received from the Ldap server.</dd>
58 /// <dt>Matched DN:</dt>
59 /// <dd>The <code>getMatchedDN</code> method retrieves the part of a
60 /// submitted distinguished name which could be matched by the server</dd>
61 /// <dt>Root Cause:</dt>
62 /// <dd>The <code>getCause</code> method returns the a nested exception
63 /// that was the original cause for the error. </dd>
66 /// The <code>toString</code> method returns a string containing all
67 /// the above sources of information, if they have a value.
69 /// Exceptions generated by the API, i.e. that are not a result
70 /// of a server response, can be identified as <tt>instanceof
71 /// {@link LdapLocalException}</tt>
73 /// The following table lists the standard Ldap result codes.
74 /// See RFC2251 for a discussion of the meanings of the result codes.
75 /// The corresponding ASN.1 definition from RFC2251 is provided in parentheses.
78 /// <td><b>Value</b></td>
79 /// <td><b>Result Code</b></td>
81 /// <tr><td> 0</td><td>{@link #SUCCESS} (success) </td></tr>
82 /// <tr><td> 1</td><td>{@link #OPERATIONS_ERROR} (operationsError) </td></tr>
83 /// <tr><td> 2</td><td>{@link #PROTOCOL_ERROR} (protocolError) </td></tr>
84 /// <tr><td> 3</td><td>{@link #TIME_LIMIT_EXCEEDED} (timeLimitExceeded) </td></tr>
85 /// <tr><td> 4</td><td>{@link #SIZE_LIMIT_EXCEEDED} (sizeLimitExceeded) </td></tr>
86 /// <tr><td> 5</td><td>{@link #COMPARE_FALSE} (compareFalse) </td></tr>
87 /// <tr><td> 6</td><td>{@link #COMPARE_TRUE} (compareTrue) </td></tr>
88 /// <tr><td> 7</td><td>{@link #AUTH_METHOD_NOT_SUPPORTED} (authMethodNotSupported) </td></tr>
89 /// <tr><td> 8</td><td>{@link #STRONG_AUTH_REQUIRED} (strongAuthRequired) </td></tr>
90 /// <tr><td> 10</td><td>{@link #REFERRAL} (referral) </td></tr>
91 /// <tr><td> 11</td><td>{@link #ADMIN_LIMIT_EXCEEDED} (adminLimitExceeded) </td></tr>
92 /// <tr><td> 12</td><td>{@link #UNAVAILABLE_CRITICAL_EXTENSION} (unavailableCriticalExtension) </td></tr>
93 /// <tr><td> 13</td><td>{@link #CONFIDENTIALITY_REQUIRED} (confidentialityRequired) </td></tr>
94 /// <tr><td> 14</td><td>{@link #SASL_BIND_IN_PROGRESS} (saslBindInProgress) </td></tr>
95 /// <tr><td> 16</td><td>{@link #NO_SUCH_ATTRIBUTE} (noSuchAttribute) </td></tr>
96 /// <tr><td> 17</td><td>{@link #UNDEFINED_ATTRIBUTE_TYPE} (undefinedAttributeType) </td></tr>
97 /// <tr><td> 18</td><td>{@link #INAPPROPRIATE_MATCHING} (inappropriateMatching) </td></tr>
98 /// <tr><td> 19</td><td>{@link #CONSTRAINT_VIOLATION} (constraintViolation) </td></tr>
99 /// <tr><td> 20</td><td>{@link #ATTRIBUTE_OR_VALUE_EXISTS} (AttributeOrValueExists) </td></tr>
100 /// <tr><td> 21</td><td>{@link #INVALID_ATTRIBUTE_SYNTAX} (invalidAttributeSyntax) </td></tr>
101 /// <tr><td> 32</td><td>{@link #NO_SUCH_OBJECT} (noSuchObject) </td></tr>
102 /// <tr><td> 33</td><td>{@link #ALIAS_PROBLEM} (aliasProblem) </td></tr>
103 /// <tr><td> 34</td><td>{@link #INVALID_DN_SYNTAX} (invalidDNSyntax) </td></tr>
104 /// <tr><td> 35</td><td>{@link #IS_LEAF} (isLeaf) </td></tr>
105 /// <tr><td> 36</td><td>{@link #ALIAS_DEREFERENCING_PROBLEM} (aliasDereferencingProblem) </td></tr>
106 /// <tr><td> 48</td><td>{@link #INAPPROPRIATE_AUTHENTICATION} (inappropriateAuthentication) </td></tr>
107 /// <tr><td> 49</td><td>{@link #INVALID_CREDENTIALS} (invalidCredentials) </td></tr>
108 /// <tr><td> 50</td><td>{@link #INSUFFICIENT_ACCESS_RIGHTS} (insufficientAccessRights) </td></tr>
109 /// <tr><td> 51</td><td>{@link #BUSY} (busy) </td></tr>
110 /// <tr><td> 52</td><td>{@link #UNAVAILABLE} (unavailable) </td></tr>
111 /// <tr><td> 53</td><td>{@link #UNWILLING_TO_PERFORM} (unwillingToPerform) </td></tr>
112 /// <tr><td> 54</td><td>{@link #LOOP_DETECT} (loopDetect) </td></tr>
113 /// <tr><td> 64</td><td>{@link #NAMING_VIOLATION} (namingViolation) </td></tr>
114 /// <tr><td> 65</td><td>{@link #OBJECT_CLASS_VIOLATION} (objectClassViolation) </td></tr>
115 /// <tr><td> 66</td><td>{@link #NOT_ALLOWED_ON_NONLEAF} (notAllowedOnNonLeaf) </td></tr>
116 /// <tr><td> 67</td><td>{@link #NOT_ALLOWED_ON_RDN} (notAllowedOnRDN) </td></tr>
117 /// <tr><td> 68</td><td>{@link #ENTRY_ALREADY_EXISTS} (entryAlreadyExists) </td></tr>
118 /// <tr><td> 69</td><td>{@link #OBJECT_CLASS_MODS_PROHIBITED} (objectClassModsProhibited) </td></tr>
119 /// <tr><td> 71</td><td>{@link #AFFECTS_MULTIPLE_DSAS} (affectsMultipleDSAs </td></tr>
120 /// <tr><td> 80</td><td>{@link #OTHER} (other) </td></tr>
123 /// Local errors, resulting from actions other than an operation on a
128 /// <td><b>Value</b></td>
129 /// <td><b>Result Code</b></td>
131 /// <tr><td>81</td><td>{@link #SERVER_DOWN}</td></tr>
132 /// <tr><td>82</td><td>{@link #LOCAL_ERROR}</td></tr>
133 /// <tr><td>83</td><td>{@link #ENCODING_ERROR}</td></tr>
134 /// <tr><td>84</td><td>{@link #DECODING_ERROR}</td></tr>
135 /// <tr><td>85</td><td>{@link #Ldap_TIMEOUT}</td></tr>
136 /// <tr><td>86</td><td>{@link #AUTH_UNKNOWN}</td></tr>
137 /// <tr><td>87</td><td>{@link #FILTER_ERROR}</td></tr>
138 /// <tr><td>88</td><td>{@link #USER_CANCELLED}</td></tr>
139 /// <tr><td>90</td><td>{@link #NO_MEMORY}</td></tr>
140 /// <tr><td>91</td><td>{@link #CONNECT_ERROR}</td></tr>
141 /// <tr><td>92</td><td>{@link #Ldap_NOT_SUPPORTED}</td></tr>
142 /// <tr><td>93</td><td>{@link #CONTROL_NOT_FOUND}</td></tr>
143 /// <tr><td>94</td><td>{@link #NO_RESULTS_RETURNED}</td></tr>
144 /// <tr><td>95</td><td>{@link #MORE_RESULTS_TO_RETURN}</td></tr>
145 /// <tr><td>96</td><td>{@link #CLIENT_LOOP}</td></tr>
146 /// <tr><td>97</td><td>{@link #REFERRAL_LIMIT_EXCEEDED}</td></tr>
147 /// <tr><td>100</td><td>{@link #INVALID_RESPONSE}</td></tr>
148 /// <tr><td>101</td><td>{@link #AMBIGUOUS_RESPONSE}</td></tr>
149 /// <tr><td>112</td><td>{@link #TLS_NOT_SUPPORTED}</td></tr>
153 public class LdapException:System.Exception
155 /// <summary> Returns the error message from the Ldap server, if this message is
156 /// available (that is, if this message was set). If the message was not set,
157 /// this method returns null.
160 /// <returns> The error message or null if the message was not set.
163 virtual public System.String LdapErrorMessage
167 if (((System.Object) serverMessage != null) && (serverMessage.Length == 0))
171 return serverMessage;
175 /// <summary> Returns the lower level Exception which caused the failure, if any.
176 /// For example, an IOException with additional information may be returned
177 /// on a CONNECT_ERROR failure.
179 virtual public System.Exception Cause
183 return rootException;
187 /// <summary> Returns the result code from the exception.
189 /// The codes are defined as <code>public final static int</code> members
190 /// of the Ldap Exception class. If the exception is a
191 /// result of error information returned from a directory operation, the
192 /// code will be one of those defined for the class. Otherwise, a local error
193 /// code is returned.
195 virtual public int ResultCode
203 /// <summary> Returns the part of a submitted distinguished name which could be
204 /// matched by the server.
206 /// If the exception was caused by a local error, such as no server
207 /// available, the return value is null. If the exception resulted from
208 /// an operation being executed on a server, the value is an empty string
209 /// except when the result of the operation was one of the following:
211 /// <li>NO_SUCH_OBJECT</li>
212 /// <li>ALIAS_PROBLEM</li>
213 /// <li>INVALID_DN_SYNTAX</li>
214 /// <li>ALIAS_DEREFERENCING_PROBLEM</li>
218 /// <returns> The part of a submitted distinguished name which could be
219 /// matched by the server or null if the error is a local error.
221 virtual public System.String MatchedDN
229 public override System.String Message
233 return resultCodeToString();
237 /* public override System.String Message
241 return resultCodeToString();
247 private int resultCode = 0;
248 // The localized message
249 private System.String messageOrKey = null;
250 // The arguments associated with the localized message
251 private System.Object[] arguments = null;
253 private System.String matchedDN = null;
255 private System.Exception rootException = null;
256 // A message from the server
257 private System.String serverMessage = null;
259 /// <summary>Indicates the requested client operation completed successfully.
263 public const int SUCCESS = 0;
265 /// <summary> Indicates an internal error.
267 /// The server is unable to respond with a more specific error and is
268 /// also unable to properly respond to a request. It does not indicate
269 /// that the client has sent an erroneous message.
271 /// OPERATIONS_ERROR = 1
273 public const int OPERATIONS_ERROR = 1;
275 /// <summary> Indicates that the server has received an invalid or malformed request
278 /// PROTOCOL_ERROR = 2
280 public const int PROTOCOL_ERROR = 2;
282 /// <summary> Indicates that the operation's time limit specified by either the
283 /// client or the server has been exceeded.
285 /// On search operations, incomplete results are returned.
287 /// TIME_LIMIT_EXCEEDED = 3
289 public const int TIME_LIMIT_EXCEEDED = 3;
291 /// <summary> Indicates that in a search operation, the size limit specified by
292 /// the client or the server has been exceeded. Incomplete results are
295 /// SIZE_LIMIT_EXCEEDED = 4
297 public const int SIZE_LIMIT_EXCEEDED = 4;
299 /// <summary> Does not indicate an error condition. Indicates that the results of
300 /// a compare operation are false.
302 /// COMPARE_FALSE = 5
304 public const int COMPARE_FALSE = 5;
306 /// <summary> Does not indicate an error condition. Indicates that the results of a
307 /// compare operation are true.
311 public const int COMPARE_TRUE = 6;
313 /// <summary> Indicates that during a bind operation the client requested an
314 /// authentication method not supported by the Ldap server.
316 /// AUTH_METHOD_NOT_SUPPORTED = 7
318 public const int AUTH_METHOD_NOT_SUPPORTED = 7;
320 /// <summary>Indicates a problem with the level of authentication.
322 /// One of the following has occurred:
324 /// <li>In bind requests, the Ldap server accepts only strong
325 /// authentication.</li>
326 /// <li>In a client request, the client requested an operation such as delete
327 /// that requires strong authentication.</li>
328 /// <li>In an unsolicited notice of disconnection, the Ldap server discovers
329 /// the security protecting the communication between the client and
330 /// server has unexpectedly failed or been compromised.</li>
332 /// STRONG_AUTH_REQUIRED = 8
334 public const int STRONG_AUTH_REQUIRED = 8;
336 /// <summary> Returned by some Ldap servers to Ldapv2 clients to indicate that a referral
337 /// has been returned in the error string.
339 /// Ldap_PARTIAL_RESULTS = 9
341 public const int Ldap_PARTIAL_RESULTS = 9;
343 /// <summary> Does not indicate an error condition. In Ldapv3, indicates that the server
344 /// does not hold the target entry of the request, but that the servers in the
345 /// referral field may.
349 public const int REFERRAL = 10;
351 /// <summary> Indicates that an Ldap server limit set by an administrative authority
352 /// has been exceeded.
354 /// ADMIN_LIMIT_EXCEEDED = 11
356 public const int ADMIN_LIMIT_EXCEEDED = 11;
358 /// <summary> Indicates that the Ldap server was unable to satisfy a request because
359 /// one or more critical extensions were not available.
361 /// Either the server does not support the control or the control is not
362 /// appropriate for the operation type.
364 /// UNAVAILABLE_CRITICAL_EXTENSION = 12
366 public const int UNAVAILABLE_CRITICAL_EXTENSION = 12;
368 /// <summary> Indicates that the session is not protected by a protocol such as
369 /// Transport Layer Security (TLS), which provides session confidentiality.
371 /// CONFIDENTIALITY_REQUIRED = 13
373 public const int CONFIDENTIALITY_REQUIRED = 13;
375 /// <summary> Does not indicate an error condition, but indicates that the server is
376 /// ready for the next step in the process. The client must send the server
377 /// the same SASL mechanism to continue the process.
379 /// SASL_BIND_IN_PROGRESS = 14
381 public const int SASL_BIND_IN_PROGRESS = 14;
383 /// <summary> Indicates that the attribute specified in the modify or compare
384 /// operation does not exist in the entry.
386 /// NO_SUCH_ATTRIBUTE = 16
388 public const int NO_SUCH_ATTRIBUTE = 16;
390 /// <summary> Indicates that the attribute specified in the modify or add operation
391 /// does not exist in the Ldap server's schema.
393 /// UNDEFINED_ATTRIBUTE_TYPE = 17
395 public const int UNDEFINED_ATTRIBUTE_TYPE = 17;
397 /// <summary> Indicates that the matching rule specified in the search filter does
398 /// not match a rule defined for the attribute's syntax.
400 /// INAPPROPRIATE_MATCHING = 18
402 public const int INAPPROPRIATE_MATCHING = 18;
404 /// <summary> Indicates that the attribute value specified in a modify, add, or
405 /// modify DN operation violates constraints placed on the attribute. The
406 /// constraint can be one of size or content (for example, string only,
409 /// CONSTRAINT_VIOLATION = 19
411 public const int CONSTRAINT_VIOLATION = 19;
413 /// <summary> Indicates that the attribute value specified in a modify or add
414 /// operation already exists as a value for that attribute.
416 /// ATTRIBUTE_OR_VALUE_EXISTS = 20
418 public const int ATTRIBUTE_OR_VALUE_EXISTS = 20;
420 /// <summary> Indicates that the attribute value specified in an add, compare, or
421 /// modify operation is an unrecognized or invalid syntax for the attribute.
423 /// INVALID_ATTRIBUTE_SYNTAX = 21
425 public const int INVALID_ATTRIBUTE_SYNTAX = 21;
427 /// <summary> Indicates the target object cannot be found.
429 /// This code is not returned on the following operations:
431 /// <li>Search operations that find the search base but cannot find any
432 /// entries that match the search filter.</li>
433 /// <li>Bind operations.</li>
435 /// NO_SUCH_OBJECT = 32
437 public const int NO_SUCH_OBJECT = 32;
439 /// <summary> Indicates that an error occurred when an alias was dereferenced.
441 /// ALIAS_PROBLEM = 33
443 public const int ALIAS_PROBLEM = 33;
445 /// <summary> Indicates that the syntax of the DN is incorrect.
447 /// If the DN syntax is correct, but the Ldap server's structure
448 /// rules do not permit the operation, the server returns
449 /// Ldap_UNWILLING_TO_PERFORM.
451 /// INVALID_DN_SYNTAX = 34
453 public const int INVALID_DN_SYNTAX = 34;
455 /// <summary> Indicates that the specified operation cannot be performed on a
458 /// This code is not currently in the Ldap specifications, but is
459 /// reserved for this constant.
463 public const int IS_LEAF = 35;
465 /// <summary> Indicates that during a search operation, either the client does not
466 /// have access rights to read the aliased object's name or dereferencing
469 /// ALIAS_DEREFERENCING_PROBLEM = 36
471 public const int ALIAS_DEREFERENCING_PROBLEM = 36;
473 /// <summary> Indicates that during a bind operation, the client is attempting to use
474 /// an authentication method that the client cannot use correctly.
476 /// For example, either of the following cause this error:
478 /// <li>The client returns simple credentials when strong credentials are
480 /// <li>The client returns a DN and a password for a simple bind when the
481 /// entry does not have a password defined.</li>
483 /// INAPPROPRIATE_AUTHENTICATION = 48
485 public const int INAPPROPRIATE_AUTHENTICATION = 48;
487 /// <summary> Indicates that invalid information was passed during a bind operation.
489 /// One of the following occurred:
491 /// <li> The client passed either an incorrect DN or password.</li>
492 /// <li> The password is incorrect because it has expired, intruder detection
493 /// has locked the account, or some other similar reason.</li>
495 /// INVALID_CREDENTIALS = 49
497 public const int INVALID_CREDENTIALS = 49;
499 /// <summary> Indicates that the caller does not have sufficient rights to perform
500 /// the requested operation.
502 /// INSUFFICIENT_ACCESS_RIGHTS = 50
504 public const int INSUFFICIENT_ACCESS_RIGHTS = 50;
506 /// <summary> Indicates that the Ldap server is too busy to process the client request
507 /// at this time, but if the client waits and resubmits the request, the
508 /// server may be able to process it then.
512 public const int BUSY = 51;
514 /// <summary> Indicates that the Ldap server cannot process the client's bind
515 /// request, usually because it is shutting down.
519 public const int UNAVAILABLE = 52;
521 /// <summary> Indicates that the Ldap server cannot process the request because of
522 /// server-defined restrictions.
524 /// This error is returned for the following reasons:
526 /// <li>The add entry request violates the server's structure rules.</li>
527 /// <li>The modify attribute request specifies attributes that users
528 /// cannot modify.</li>
530 /// UNWILLING_TO_PERFORM = 53
532 public const int UNWILLING_TO_PERFORM = 53;
534 /// <summary> Indicates that the client discovered an alias or referral loop,
535 /// and is thus unable to complete this request.
539 public const int LOOP_DETECT = 54;
541 /// <summary> Indicates that the add or modify DN operation violates the schema's
546 /// <li>The request places the entry subordinate to an alias.</li>
547 /// <li>The request places the entry subordinate to a container that
548 /// is forbidden by the containment rules.</li>
549 /// <li>The RDN for the entry uses a forbidden attribute type.</li>
551 /// NAMING_VIOLATION = 64
553 public const int NAMING_VIOLATION = 64;
555 /// <summary> Indicates that the add, modify, or modify DN operation violates the
556 /// object class rules for the entry.
558 /// For example, the following types of request return this error:
560 /// <li>The add or modify operation tries to add an entry without a value
561 /// for a required attribute.</li>
562 /// <li>The add or modify operation tries to add an entry with a value for
563 /// an attribute which the class definition does not contain.</li>
564 /// <li>The modify operation tries to remove a required attribute without
565 /// removing the auxiliary class that defines the attribute as required.</li>
567 /// OBJECT_CLASS_VIOLATION = 65
569 public const int OBJECT_CLASS_VIOLATION = 65;
571 /// <summary> Indicates that the requested operation is permitted only on leaf entries.
573 /// For example, the following types of requests return this error:
575 /// <li>The client requests a delete operation on a parent entry.</li>
576 /// <li> The client request a modify DN operation on a parent entry.</li>
578 /// NOT_ALLOWED_ON_NONLEAF = 66
580 public const int NOT_ALLOWED_ON_NONLEAF = 66;
582 /// <summary> Indicates that the modify operation attempted to remove an attribute
583 /// value that forms the entry's relative distinguished name.
585 /// NOT_ALLOWED_ON_RDN = 67
587 public const int NOT_ALLOWED_ON_RDN = 67;
589 /// <summary> Indicates that the add operation attempted to add an entry that already
590 /// exists, or that the modify operation attempted to rename an entry to the
591 /// name of an entry that already exists.
593 /// ENTRY_ALREADY_EXISTS = 68
595 public const int ENTRY_ALREADY_EXISTS = 68;
597 /// <summary> Indicates that the modify operation attempted to modify the structure
598 /// rules of an object class.
600 /// OBJECT_CLASS_MODS_PROHIBITED = 69
602 public const int OBJECT_CLASS_MODS_PROHIBITED = 69;
604 /// <summary> Indicates that the modify DN operation moves the entry from one Ldap
605 /// server to another and thus requires more than one Ldap server.
607 /// AFFECTS_MULTIPLE_DSAS = 71
609 public const int AFFECTS_MULTIPLE_DSAS = 71;
611 /// <summary> Indicates an unknown error condition.
615 public const int OTHER = 80;
617 /////////////////////////////////////////////////////////////////////////////
618 // Local Errors, resulting from actions other than an operation on a server
619 /////////////////////////////////////////////////////////////////////////////
621 /// <summary> Indicates that the Ldap libraries cannot establish an initial connection
622 /// with the Ldap server. Either the Ldap server is down or the specified
623 /// host name or port number is incorrect.
627 public const int SERVER_DOWN = 81;
629 /// <summary> Indicates that the Ldap client has an error. This is usually a failed
630 /// dynamic memory allocation error.
634 public const int LOCAL_ERROR = 82;
636 /// <summary> Indicates that the Ldap client encountered errors when encoding an
637 /// Ldap request intended for the Ldap server.
639 /// ENCODING_ERROR = 83
641 public const int ENCODING_ERROR = 83;
643 /// <summary> Indicates that the Ldap client encountered errors when decoding an
644 /// Ldap response from the Ldap server.
646 /// DECODING_ERROR = 84
648 public const int DECODING_ERROR = 84;
650 /// <summary> Indicates that the time limit of the Ldap client was exceeded while
651 /// waiting for a result.
653 /// Ldap_TIMEOUT = 85
655 public const int Ldap_TIMEOUT = 85;
657 /// <summary> Indicates that a bind method was called with an unknown
658 /// authentication method.
660 /// AUTH_UNKNOWN = 86
662 public const int AUTH_UNKNOWN = 86;
664 /// <summary> Indicates that the search method was called with an invalid
667 /// FILTER_ERROR = 87
669 public const int FILTER_ERROR = 87;
671 /// <summary> Indicates that the user cancelled the Ldap operation.
673 /// USER_CANCELLED = 88
675 public const int USER_CANCELLED = 88;
678 /// <summary> Indicates that a dynamic memory allocation method failed when calling
683 public const int NO_MEMORY = 90;
685 /// <summary> Indicates that the Ldap client has lost either its connection or
686 /// cannot establish a connection to the Ldap server.
688 /// CONNECT_ERROR = 91
690 public const int CONNECT_ERROR = 91;
692 /// <summary> Indicates that the requested functionality is not supported by the
693 /// client. For example, if the Ldap client is established as an Ldapv2
694 /// client, the libraries set this error code when the client requests
695 /// Ldapv3 functionality.
697 /// Ldap_NOT_SUPPORTED = 92
699 public const int Ldap_NOT_SUPPORTED = 92;
701 /// <summary> Indicates that the client requested a control that the libraries
702 /// cannot find in the list of supported controls sent by the Ldap server.
704 /// CONTROL_NOT_FOUND = 93
706 public const int CONTROL_NOT_FOUND = 93;
708 /// <summary> Indicates that the Ldap server sent no results.
710 /// NO_RESULTS_RETURNED = 94
712 public const int NO_RESULTS_RETURNED = 94;
714 /// <summary> Indicates that more results are chained in the result message.
716 /// MORE_RESULTS_TO_RETURN = 95
718 public const int MORE_RESULTS_TO_RETURN = 95;
720 /// <summary> Indicates the Ldap libraries detected a loop. Usually this happens
721 /// when following referrals.
725 public const int CLIENT_LOOP = 96;
727 /// <summary> Indicates that the referral exceeds the hop limit. The default hop
730 /// The hop limit determines how many servers the client can hop through
731 /// to retrieve data. For example, suppose the following conditions:
733 /// <li>Suppose the hop limit is two.</li>
734 /// <li> If the referral is to server D which can be contacted only through
735 /// server B (1 hop) which contacts server C (2 hops) which contacts
736 /// server D (3 hops).</li>
738 /// With these conditions, the hop limit is exceeded and the Ldap
739 /// libraries set this code.
741 /// REFERRAL_LIMIT_EXCEEDED = 97
743 public const int REFERRAL_LIMIT_EXCEEDED = 97;
745 /// <summary> Indicates that the server response to a request is invalid.
747 /// INVALID_RESPONSE = 100
749 public const int INVALID_RESPONSE = 100;
751 /// <summary> Indicates that the server response to a request is ambiguous.
753 /// AMBIGUOUS_RESPONSE = 101
755 public const int AMBIGUOUS_RESPONSE = 101;
757 /// <summary> Indicates that TLS is not supported on the server.
759 /// TLS_NOT_SUPPORTED = 112
761 public const int TLS_NOT_SUPPORTED = 112;
763 /// <summary> Indicates that SSL Handshake could not succeed.
765 /// SSL_HANDSHAKE_FAILED = 113
767 public const int SSL_HANDSHAKE_FAILED = 113;
769 /// <summary> Indicates that SSL Provider could not be found.
771 /// SSL_PROVIDER_NOT_FOUND = 114
773 public const int SSL_PROVIDER_NOT_FOUND = 114;
775 * Note: Error strings have been pulled out into
776 * ResultCodeMessages.properties
779 /// <summary> Constructs a default exception with no specific error information.</summary>
780 public LdapException():base()
785 /// <summary> Constructs an exception with a detailed message obtained from the
786 /// specified <code>MessageOrKey</code> String, the result code,
787 /// and a server meessage.
789 /// The String is used either as a message key to obtain a localized
790 /// messsage from ExceptionMessages, or if there is no key in the
791 /// resource matching the text, it is used as the detailed message itself.
794 /// <param name="messageOrKey"> Key to addition result information, a key into
795 /// ExceptionMessages, or the information
796 /// itself if the key doesn't exist.
799 /// <param name="resultCode"> The result code returned.
802 /// <param name="serverMsg"> Error message specifying additional information
805 public LdapException(System.String messageOrKey, int resultCode, System.String serverMsg):this(messageOrKey, null, resultCode, serverMsg, null, null)
810 /// <summary> Constructs an exception with a detailed message obtained from the
811 /// specified <code>MessageOrKey</code> String and modifying arguments.
812 /// Additional parameters specify the result code and server message.
814 /// The String is used either as a message key to obtain a localized
815 /// messsage from ExceptionMessages, or if there is no key in the
816 /// resource matching the text, it is used as the detailed message itself.
818 /// The message in the default locale is built with the supplied arguments,
819 /// which are saved to be used for building messages for other locales.
822 /// <param name="messageOrKey"> Key to addition result information, a key into
823 /// ExceptionMessages, or the information
824 /// itself if the key doesn't exist.
827 /// <param name="arguments"> The modifying arguments to be included in the
831 /// <param name="serverMsg"> Error message specifying additional information
835 /// <param name="resultCode"> The result code returned.
837 public LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg):this(messageOrKey, arguments, resultCode, serverMsg, null, null)
842 /// <summary> Constructs an exception with a detailed message obtained from the
843 /// specified <code>MessageOrKey</code> String.
844 /// Additional parameters specify the result code, the server message, and a
845 /// rootException which is the underlying cause of an error on the client.
847 /// The String is used either as a message key to obtain a localized
848 /// messsage from ExceptionMessages, or if there is no key in the
849 /// resource matching the text, it is used as the detailed message itself.
852 /// <param name="messageOrKey"> Key to addition result information, a key into
853 /// ExceptionMessages, or the information
854 /// itself if the key doesn't exist.
857 /// <param name="resultCode"> The result code returned.
860 /// <param name="serverMsg"> Error message specifying additional information
864 /// <param name="rootException"> A throwable which is the underlying cause
865 /// of the LdapException.
867 public LdapException(System.String messageOrKey, int resultCode, System.String serverMsg, System.Exception rootException):this(messageOrKey, null, resultCode, serverMsg, null, rootException)
872 /// <summary> Constructs an exception with a detailed message obtained from the
873 /// specified <code>MessageOrKey</code> String and modifying arguments.
874 /// Additional parameters specify the result code, the server message,
875 /// and a rootException which is the underlying cause of an error
878 /// The String is used either as a message key to obtain a localized
879 /// messsage from ExceptionMessages, or if there is no key in the
880 /// resource matching the text, it is used as the detailed message itself.
882 /// The message in the default locale is built with the supplied arguments,
883 /// which are saved to be used for building messages for other locales.
886 /// <param name="messageOrKey"> Key to addition result information, a key into
887 /// ExceptionMessages, or the information
888 /// itself if the key doesn't exist.
891 /// <param name="arguments"> The modifying arguments to be included in the
895 /// <param name="resultCode"> The result code returned.
898 /// <param name="serverMsg"> Error message specifying additional information
902 /// <param name="rootException"> A throwable which is the underlying cause
903 /// of the LdapException.
905 public LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg, System.Exception rootException):this(messageOrKey, arguments, resultCode, serverMsg, null, rootException)
910 /// <summary> Constructs an exception with a detailed message obtained from the
911 /// specified <code>MessageOrKey</code> String.
912 /// Additional parameters specify the result code, the message returned
913 /// from the server, and a matchedDN returned from the server.
915 /// The String is used either as a message key to obtain a localized
916 /// messsage from ExceptionMessages, or if there is no key in the
917 /// resource matching the text, it is used as the detailed message itself.
920 /// <param name="messageOrKey"> Key to addition result information, a key into
921 /// ExceptionMessages, or the information
922 /// itself if the key doesn't exist.
925 /// <param name="resultCode"> The result code returned.
928 /// <param name="serverMsg"> Error message specifying additional information
932 /// <param name="matchedDN"> The maximal subset of a specified DN which could
933 /// be matched by the server on a search operation.
935 public LdapException(System.String messageOrKey, int resultCode, System.String serverMsg, System.String matchedDN):this(messageOrKey, null, resultCode, serverMsg, matchedDN, null)
940 /// <summary> Constructs an exception with a detailed message obtained from the
941 /// specified <code>MessageOrKey</code> String and modifying arguments.
942 /// Additional parameters specify the result code, a message returned from
943 /// the server, and a matchedDN returned from the server.
945 /// The String is used either as a message key to obtain a localized
946 /// messsage from ExceptionMessages, or if there is no key in the
947 /// resource matching the text, it is used as the detailed message itself.
949 /// The message in the default locale is built with the supplied arguments,
950 /// which are saved to be used for building messages for other locales.
953 /// <param name="messageOrKey"> Key to addition result information, a key into
954 /// ExceptionMessages, or the information
955 /// itself if the key doesn't exist.
958 /// <param name="arguments"> The modifying arguments to be included in the
962 /// <param name="resultCode"> The result code returned.
965 /// <param name="serverMsg"> Error message specifying additional information
969 /// <param name="matchedDN"> The maximal subset of a specified DN which could
970 /// be matched by the server on a search operation.
972 public LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg, System.String matchedDN):this(messageOrKey, arguments, resultCode, serverMsg, matchedDN, null)
977 /// <summary> Constructs an exception with a detailed message obtained from the
978 /// specified <code>MessageOrKey</code> String and modifying arguments.
979 /// Additional parameters specify the result code, a message returned
980 /// from the server, a matchedDN returned from
981 /// the server, and a rootException which is the underlying cause of an error
984 /// The String is used either as a message key to obtain a localized
985 /// messsage from ExceptionMessages, or if there is no key in the
986 /// resource matching the text, it is used as the detailed message itself.
988 /// The message in the default locale is built with the supplied arguments,
989 /// which are saved to be used for building messages for other locales.
992 /// <param name="messageOrKey"> Key to addition result information, a key into
993 /// ExceptionMessages, or the information
994 /// itself if the key doesn't exist.
997 /// <param name="arguments"> The modifying arguments to be included in the
1001 /// <param name="resultCode"> The result code returned.
1004 /// <param name="serverMsg"> Error message specifying additional information
1008 /// <param name="rootException"> A throwable which is the underlying cause
1009 /// of the LdapException.
1012 /// <param name="matchedDN"> The maximal subset of a specified DN which could
1013 /// be matched by the server on a search operation.
1016 internal LdapException(System.String messageOrKey, System.Object[] arguments, int resultCode, System.String serverMsg, System.String matchedDN, System.Exception rootException)
1017 //:base(Novell.Directory.Ldap.Utilclass.ResourcesHandler.getMessage(messageOrKey, arguments))
1018 //Once resorcehandler starts working properly need to uncomment
1020 this.messageOrKey = messageOrKey;
1021 this.arguments = arguments;
1022 this.resultCode = resultCode;
1023 this.rootException = rootException;
1024 this.matchedDN = matchedDN;
1025 this.serverMessage = serverMsg;
1029 /// <summary> Returns a string representing the result code in the default
1033 /// <returns> The message for the result code in the LdapException object.
1035 public virtual System.String resultCodeToString()
1037 return ResourcesHandler.getResultString(resultCode);
1040 /// <summary> Returns a string representing the specified result code in the default
1044 /// <param name="code"> The result code for which a message is to be returned.
1047 /// <returns> The message corresponding to the specified result code, or
1048 /// or null if the message is not available for the default locale.
1050 public static System.String resultCodeToString(int code)
1052 return ResourcesHandler.getResultString(code);
1055 /// <summary> Returns a string representing the result code in the
1056 /// specified locale.
1059 /// <param name="locale">The locale in which to render the error message.
1062 /// <returns> A message corresponding to the result code in the
1063 /// specified locale, or null if the message is not available
1064 /// for the requested locale.
1066 public virtual System.String resultCodeToString(System.Globalization.CultureInfo locale)
1068 return ResourcesHandler.getResultString(resultCode, locale);
1071 /// <summary> Returns a string representing the specified error code in the
1072 /// specified locale.
1075 /// <param name="code"> The result code for which a message is to be
1079 /// <param name="locale"> The locale in which to render the message.
1082 /// <returns> A message corresponding to the result code in the
1083 /// specified locale, or null if the message is not available
1084 /// for the requested locale.
1086 public static System.String resultCodeToString(int code, System.Globalization.CultureInfo locale)
1088 return ResourcesHandler.getResultString(code, locale);
1091 /// <summary> returns a string of information about the exception and the
1092 /// the nested exceptions, if any.
1094 public override System.String ToString()
1096 return getExceptionString("LdapException");
1099 /// <summary> builds a string of information about the exception and the
1100 /// the nested exceptions, if any.
1103 /// <param name="exception">The name of the exception class
1106 internal virtual System.String getExceptionString(System.String exception)
1110 // Format the basic exception information
1112 // Craft a string from the resouce file
1113 System.String msg = ResourcesHandler.getMessage("TOSTRING", new System.Object[]{exception, base.Message, resultCode, resultCodeToString()});
1114 // If found no string from resource file, use a default string
1115 if (msg.ToUpper().Equals("TOSTRING".ToUpper()))
1117 msg = exception + ": (" + resultCode + ") " + resultCodeToString();
1120 // Add server message
1121 if (((System.Object) serverMessage != null) && (serverMessage.Length != 0))
1123 tmsg = ResourcesHandler.getMessage("SERVER_MSG", new System.Object[]{exception, serverMessage});
1124 // If found no string from resource file, use a default string
1125 if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
1127 tmsg = exception + ": Server Message: " + serverMessage;
1130 msg = msg + '\n' + tmsg;
1133 // Add Matched DN message
1134 if ((System.Object) matchedDN != null)
1136 tmsg = ResourcesHandler.getMessage("MATCHED_DN", new System.Object[]{exception, matchedDN});
1137 // If found no string from resource file, use a default string
1138 if (tmsg.ToUpper().Equals("MATCHED_DN".ToUpper()))
1140 tmsg = exception + ": Matched DN: " + matchedDN;
1143 msg = msg + '\n' + tmsg;
1146 if (rootException != null)
1148 msg = msg + '\n' + rootException.ToString();