001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.shared.ldap.message;
021    
022    
023    import java.util.Set;
024    import java.util.HashSet;
025    import java.util.Collections;
026    
027    import javax.naming.AuthenticationException;
028    import javax.naming.AuthenticationNotSupportedException;
029    import javax.naming.CommunicationException;
030    import javax.naming.ContextNotEmptyException;
031    import javax.naming.InvalidNameException;
032    import javax.naming.LimitExceededException;
033    import javax.naming.NameAlreadyBoundException;
034    import javax.naming.NameNotFoundException;
035    import javax.naming.NamingException;
036    import javax.naming.NoPermissionException;
037    import javax.naming.OperationNotSupportedException;
038    import javax.naming.PartialResultException;
039    import javax.naming.ServiceUnavailableException;
040    import javax.naming.SizeLimitExceededException;
041    import javax.naming.TimeLimitExceededException;
042    import javax.naming.directory.AttributeInUseException;
043    import javax.naming.directory.InvalidAttributeIdentifierException;
044    import javax.naming.directory.InvalidAttributeValueException;
045    import javax.naming.directory.InvalidSearchFilterException;
046    import javax.naming.directory.NoSuchAttributeException;
047    import javax.naming.directory.SchemaViolationException;
048    
049    import org.apache.directory.shared.ldap.exception.LdapException;
050    
051    
052    /**
053     * Type safe LDAP message envelope result code enumeration. The resultCode is a
054     * parameter of the LDAPResult which is the construct used in this protocol to
055     * return success or failure indications from servers to clients. In response to
056     * various requests servers will return responses containing fields of type
057     * LDAPResult to indicate the final status of a protocol operation request. This
058     * enumeration represents the various status codes associated with an
059     * LDAPResult, hence it is called the ResultCodeEnum. Here are the definitions
060     * and values for error codes from section 4.1.10 of <a
061     * href="http://www.faqs.org/rfcs/rfc2251.html">RFC 2251</a>:
062     * 
063     * <pre><code>
064     *     resultCode
065     *        ENUMERATED {
066     *           success                      (0),
067     *           operationsError              (1),
068     *           protocolError                (2),
069     *           timeLimitExceeded            (3),
070     *           sizeLimitExceeded            (4),
071     *           compareFalse                 (5),
072     *           compareTrue                  (6),
073     *           authMethodNotSupported       (7),
074     *           strongAuthRequired           (8),
075     *           partialResults               (9),   -- new
076     *           referral                     (10),  -- new
077     *           adminLimitExceeded           (11),  -- new
078     *           unavailableCriticalExtension (12),  -- new
079     *           confidentialityRequired      (13),  -- new
080     *           saslBindInProgress           (14),  -- new
081     *           noSuchAttribute              (16),
082     *           undefinedAttributeType       (17),
083     *           inappropriateMatching        (18),
084     *           constraintViolation          (19),
085     *           attributeOrValueExists       (20),
086     *           invalidAttributeSyntax       (21),
087     *           -- 22-31 unused --
088     *           NO_SUCH_OBJECT                 (32),
089     *           aliasProblem                 (33),
090     *           invalidDNSyntax              (34),
091     *           -- 35 reserved for undefined isLeaf --
092     *           aliasDereferencingProblem    (36),
093     *           -- 37-47 unused --
094     *           inappropriateAuthentication  (48),
095     *           invalidCredentials           (49),
096     *           insufficientAccessRights     (50),
097     *           busy                         (51),
098     *           unavailable                  (52),
099     *           unwillingToPerform           (53),
100     *           loopDetect                   (54),
101     *           -- 55-63 unused --
102     *           namingViolation              (64),
103     *           objectClassViolation         (65),
104     *           notAllowedOnNonLeaf          (66),
105     *           notAllowedOnRDN              (67),
106     *           entryAlreadyExists           (68),
107     *           objectClassModsProhibited    (69),
108     *           -- 70 reserved for CLDAP --
109     *           affectsMultipleDSAs          (71), -- new
110     *           -- 72-79 unused --
111     *           other                        (80) },
112     *           -- 81-90 reserved for APIs --
113     * </code></pre>
114     * 
115     * All the result codes with the exception of success, compareFalse and
116     * compareTrue are to be treated as meaning the operation could not be completed
117     * in its entirety. Most of the result codes are based on problem indications
118     * from X.511 error data types. Result codes from 16 to 21 indicate an
119     * AttributeProblem, codes 32, 33, 34 and 36 indicate a NameProblem, codes 48,
120     * 49 and 50 indicate a SecurityProblem, codes 51 to 54 indicate a
121     * ServiceProblem, and codes 64 to 69 and 71 indicates an UpdateProblem. If a
122     * client receives a result code which is not listed above, it is to be treated
123     * as an unknown error condition. The majority of this javadoc was pasted in
124     * from RFC 2251. There's and expired draft out there on error codes which makes
125     * alot of sense: <a
126     * href="http://www.alternic.org/drafts/drafts-j-k/draft-just-ldapv3-rescodes-
127     * 02.html"> ietf (expired) draft</a> on error codes (read at your discretion).
128     * Result codes have been identified and split into categories:
129     * <ul>
130     * <li> Non-Erroneous: Five result codes that may be returned in LDAPResult are
131     * not used to indicate an error. </li>
132     * <li> General: returned only when no suitable specific error exists. </li>
133     * <li> Specific: Specific errors are used to indicate that a particular type of
134     * error has occurred. These error types are:
135     * <ul>
136     * <li> Name, </li>
137     * <li> Update, </li>
138     * <li> Attribute </li>
139     * <li> Security, and </li>
140     * <li> Service </li>
141     * </ul>
142     * </li>
143     * </ul>
144     * The result codes are also grouped according to the following LDAP operations
145     * which return responses:
146     * <ul>
147     * <li> bind </li>
148     * <li> search </li>
149     * <li> modify </li>
150     * <li> modifyDn </li>
151     * <li> add </li>
152     * <li> delete </li>
153     * <li> compare </li>
154     * <li> extended </li>
155     * </ul>
156     * 
157     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
158     * @version $Revision: 774841 $
159     */
160    public enum ResultCodeEnum
161    {
162        // ------------------------------------------------------------------------
163        // Public Static Constants: Enumeration values and names.
164        // ------------------------------------------------------------------------
165        // ------------------------------------------------------------------------
166        // Non Erroneous Codes:
167        //
168        // Five result codes that may be returned in LDAPResult are not used to
169        // indicate an error. These result codes are listed below. The first
170        // three codes, indicate to the client that no further action is required
171        // in order to satisfy their request. In contrast, the last two errors
172        // require further action by the client in order to complete their original
173        // operation request.
174        // ------------------------------------------------------------------------
175    
176        /**
177         * It is returned when the client operation completed successfully without
178         * errors. This code is one of 5 result codes that may be returned in the
179         * LDAPResult which are not used to indicate an error. Applicable
180         * operations: all except for Compare. Result code type: Non-Erroneous
181         */
182        SUCCESS( 0 ),
183    
184        /**
185         * Servers sends this result code to LDAP v2 clients to refer them to
186         * another LDAP server. When sending this code to a client, the server
187         * includes a newline-delimited list of LDAP URLs that identify another LDAP
188         * server. If the client identifies itself as an LDAP v3 client in the
189         * request, servers send an REFERRAL result code instead of this result
190         * code.
191         */
192        PARTIAL_RESULTS( 9 ),
193    
194        /**
195         * It is used to indicate that the result of a Compare operation is FALSE
196         * and does not indicate an error. 1 of 5 codes that do not indicate an
197         * error condition. Applicable operations: Compare. Result code type:
198         * Non-Erroneous
199         */
200        COMPARE_FALSE( 5 ),
201    
202        /**
203         * It is used to indicate that the result of a Compare operation is TRUE and
204         * does not indicate an error. 1 of 5 codes that do not indicate an error
205         * condition. Applicable operations: Compare. Result code type:
206         * Non-Erroneous
207         */
208        COMPARE_TRUE( 6 ),
209    
210        /**
211         * Rather than indicating an error, this result code is used to indicate
212         * that the server does not hold the target entry of the request but is able
213         * to provide alternative servers that may. A set of server(s) URLs may be
214         * returned in the referral field, which the client may subsequently query
215         * to attempt to complete their operation. 1 of 5 codes that do not indicate
216         * an error condition yet requires further action on behalf of the client to
217         * complete the request. This result code is new in LDAPv3. Applicable
218         * operations: all. Result code type: Non-Erroneous
219         */
220        REFERRAL( 10 ),
221    
222        /**
223         * This result code is not an error response from the server, but rather, is
224         * a request for bind continuation. The server requires the client to send a
225         * new bind request, with the same SASL mechanism, to continue the
226         * authentication process [RFC2251, Section 4.2.3]. This result code is new
227         * in LDAPv3. Applicable operations: Bind. Result code type: Non-Erroneous
228         */
229        SASL_BIND_IN_PROGRESS( 14 ),
230    
231        // ------------------------------------------------------------------------
232        // Problem Specific Error Codes:
233        //
234        // Specific errors are used to indicate that a particular type of error
235        // has occurred. These error types are Name, Update, Attribute, Security,
236        // and Service.
237        // ------------------------------------------------------------------------
238        // ------------------------------------------------------------------------
239        // Security Problem Specific Error Codes:
240        //
241        // A security error reports a problem in carrying out an operation for
242        // security reasons [X511, Section 12.7].
243        // ------------------------------------------------------------------------
244    
245        /**
246         * This error code should be returned if the client requests, in a Bind
247         * request, an authentication method which is not supported or recognized by
248         * the server. Applicable operations: Bind. Result code type: Specific
249         * (Security)
250         */
251        AUTH_METHOD_NOT_SUPPORTED( 7 ),
252    
253        /**
254         * This error may be returned on a bind request if the server only accepts
255         * strong authentication or it may be returned when a client attempts an
256         * operation which requires the client to be strongly authenticated - for
257         * example Delete. This result code may also be returned in an unsolicited
258         * notice of disconnection if the server detects that an established
259         * underlying security association protecting communication between the
260         * client and server has unexpectedly failed or been compromised. [RFC2251,
261         * Section 4.4.1] Applicable operations: all. Result code type: Specific
262         * (Security)
263         */
264        STRONG_AUTH_REQUIRED( 8 ),
265    
266        /**
267         * This error code may be returned if the session is not protected by a
268         * protocol which provides session confidentiality. For example, if the
269         * client did not establish a TLS connection using a cipher suite which
270         * provides confidentiality of the session before sending any other
271         * requests, and the server requires session confidentiality then the server
272         * may reject that request with a result code of confidentialityRequired.
273         * This error code is new in LDAPv3. Applicable operations: all. Result code
274         * type: Specific (Security)
275         */
276        CONFIDENTIALITY_REQUIRED( 13 ),
277    
278        /**
279         * An alias was encountered in a situation where it was not allowed or where
280         * access was denied [X511, Section 12.5]. For example, if the client does
281         * not have read permission for the aliasedObjectName attribute and its
282         * value then the error aliasDereferencingProblem should be returned. [X511,
283         * Section 7.11.1.1] Notice that this error has similar meaning to
284         * INSUFFICIENT_ACCESS_RIGHTS (50), but is specific to Searching on an alias.
285         * Applicable operations: Search. Result code type: Specific (Security)
286         */
287        ALIAS_DEREFERENCING_PROBLEM( 36 ),
288    
289        /**
290         * This error should be returned by the server when the client has tried to
291         * use a method of authentication that is inappropriate, that is a method of
292         * authentication which the client is unable to use correctly. In other
293         * words, the level of security associated with the requestor's credentials
294         * is inconsistent with the level of protection requested, e.g. simple
295         * credentials were supplied while strong credentials were required [X511,
296         * Section 12.7]. Applicable operations: Bind. Result code type: Specific
297         * (Security)
298         */
299        INAPPROPRIATE_AUTHENTICATION( 48 ),
300    
301        /**
302         * This error code is returned if the DN or password used in a simple bind
303         * operation is incorrect, or if the DN or password is incorrect for some
304         * other reason, e.g. the password has expired. This result code only
305         * applies to Bind operations -- it should not be returned for other
306         * operations if the client does not have sufficient permission to perform
307         * the requested operation - in this case the return code should be
308         * insufficientAccessRights. Applicable operations: Bind. Result code type:
309         * Specific (Security)
310         */
311        INVALID_CREDENTIALS( 49 ),
312    
313        /**
314         * The requestor does not have the right to carry out the requested
315         * operation [X511, Section 12.7]. Note that the more specific
316         * aliasDereferencingProblem is returned in case of a Search on an alias
317         * where the requestor has insufficientAccessRights. Applicable operations:
318         * all except for Bind. Result code type: Specific (Security)
319         */
320        INSUFFICIENT_ACCESS_RIGHTS( 50 ),
321    
322        // ------------------------------------------------------------------------
323        // Service Problem Specific Error Codes:
324        //
325        // A service error reports a problem related to the provision of the
326        // service [X511, Section 12.8].
327        // ------------------------------------------------------------------------
328    
329        /**
330         * If the server requires that the client bind before browsing or modifying
331         * the directory, the server MAY reject a request other than binding,
332         * unbinding or an extended request with the "operationsError" result.
333         * [RFC2251, Section 4.2.1] Applicable operations: all except Bind. Result
334         * code type: Specific (Service)
335         */
336        OPERATIONS_ERROR( 1 ),
337    
338        /**
339         * A protocol error should be returned by the server when an invalid or
340         * malformed request is received from the client. This may be a request that
341         * is not recognized as an LDAP request, for example, if a nonexistent
342         * operation were specified in LDAPMessage. As well, it may be the result of
343         * a request that is missing a required parameter, such as a search filter
344         * in a search request. If the server can return an error, which is more
345         * specific than protocolError, then this error should be returned instead.
346         * For example if the server does not recognize the authentication method
347         * requested by the client then the error authMethodNotSupported should be
348         * returned instead of protocolError. The server may return details of the
349         * error in the error string. Applicable operations: all. Result code type:
350         * Specific (Service)
351         */
352        PROTOCOL_ERROR( 2 ),
353    
354        /**
355         * This error should be returned when the time to perform an operation has
356         * exceeded either the time limit specified by the client (which may only be
357         * set by the client in a search operation) or the limit specified by the
358         * server. If the time limit is exceeded on a search operation then the
359         * result is an arbitrary selection of the accumulated results [X511,
360         * Section 7.5]. Note that an arbitrary selection of results may mean that
361         * no results are returned to the client. If the LDAP server is a front end
362         * for an X.500 server, any operation that is chained may exceed the
363         * timelimit, therefore clients can expect to receive timelimitExceeded for
364         * all operations. For stand alone LDAP- Servers that do not implement
365         * chaining it is unlikely that operations other than search operations will
366         * exceed the defined timelimit. Applicable operations: all. Result code
367         * type: Specific (Service)
368         */
369        TIME_LIMIT_EXCEEDED( 3 ),
370    
371        /**
372         * This error should be returned when the number of results generated by a
373         * search exceeds the maximum number of results specified by either the
374         * client or the server. If the size limit is exceeded then the results of a
375         * search operation will be an arbitrary selection of the accumulated
376         * results, equal in number to the size limit [X511, Section 7.5].
377         * Applicable operations: Search. Result code type: Specific (Service)
378         */
379        SIZE_LIMIT_EXCEEDED( 4 ),
380    
381        /**
382         * The server has reached some limit set by an administrative authority, and
383         * no partial results are available to return to the user [X511, Section
384         * 12.8]. For example, there may be an administrative limit to the number of
385         * entries a server will check when gathering potential search result
386         * candidates [Net]. This error code is new in LDAPv3. Applicable
387         * operations: all. Result code type: Specific (Service)
388         */
389        ADMIN_LIMIT_EXCEEDED( 11 ),
390    
391        /**
392         * The server was unable to satisfy the request because one or more critical
393         * extensions were not available [X511, Section 12.8]. This error is
394         * returned, for example, when a control submitted with a request is marked
395         * critical but is not recognized by a server or when such a control is not
396         * appropriate for the operation type. [RFC2251 section 4.1.12]. This error
397         * code is new in LDAPv3. Applicable operations: all. Result code type:
398         * Specific (Service)
399         */
400        UNAVAILABLE_CRITICAL_EXTENSION( 12 ),
401    
402        /**
403         * This error code may be returned if the server is unable to process the
404         * client's request at this time. This implies that if the client retries
405         * the request shortly the server will be able to process it then.
406         * Applicable operations: all. Result code type: Specific (Service)
407         */
408        BUSY( 51 ),
409    
410        /**
411         * This error code is returned when the server is unavailable to process the
412         * client's request. This usually means that the LDAP server is shutting
413         * down [RFC2251, Section 4.2.3]. Applicable operations: all. Result code
414         * type: Specific (Service)
415         */
416        UNAVAILABLE( 52 ),
417    
418        /**
419         * This error code should be returned by the server when a client request is
420         * properly formed but which the server is unable to complete due to
421         * server-defined restrictions. For example, the server, or some part of it,
422         * is not prepared to execute this request, e.g. because it would lead to
423         * excessive consumption of resources or violates the policy of an
424         * Administrative Authority involved [X511, Section 12.8]. If the server is
425         * able to return a more specific error code such as adminLimitExceeded it
426         * should. This error may also be returned if the client attempts to modify
427         * attributes which can not be modified by users, e.g., operational
428         * attributes such as creatorsName or createTimestamp [X511, Section 7.12].
429         * If appropriate, details of the error should be provided in the error
430         * message. Applicable operations: all. Result code type: Specific (Service)
431         */
432        UNWILLING_TO_PERFORM( 53 ),
433    
434        /**
435         * This error may be returned by the server if it detects an alias or
436         * referral loop, and is unable to satisfy the client's request. Applicable
437         * operations: all. Result code type: Specific (Service)
438         */
439        LOOP_DETECT( 54 ),
440    
441        // ------------------------------------------------------------------------
442        // Attribute Problem Specific Error Codes:
443        //
444        // An attribute error reports a problem related to an attribute specified
445        // by the client in their request message.
446        // ------------------------------------------------------------------------
447    
448        /**
449         * This error may be returned if the attribute specified as an argument of
450         * the operation does not exist in the entry. Applicable operations: Modify,
451         * Compare. Result code type: Specific (Attribute)
452         */
453        NO_SUCH_ATTRIBUTE( 16 ),
454    
455        /**
456         * This error may be returned if the specified attribute is unrecognized by
457         * the server, since it is not present in the server's defined schema. If
458         * the server doesn't recognize an attribute specified in a search request
459         * as the attribute to be returned the server should not return an error in
460         * this case - it should just return values for the requested attributes it
461         * does recognize. Note that this result code only applies to the Add and
462         * Modify operations [X.511, Section 12.4]. Applicable operations: Modify,
463         * Add. Result code type: Specific (Attribute)
464         */
465        UNDEFINED_ATTRIBUTE_TYPE( 17 ),
466    
467        /**
468         * An attempt was made, e.g., in a filter, to use a matching rule not
469         * defined for the attribute type concerned [X511, Section 12.4]. Applicable
470         * operations: Search. Result code type: Specific (Attribute)
471         */
472        INAPPROPRIATE_MATCHING( 18 ),
473    
474        /**
475         * This error should be returned by the server if an attribute value
476         * specified by the client violates the constraints placed on the attribute
477         * as it was defined in the DSA - this may be a size constraint or a
478         * constraint on the content. Applicable operations: Modify, Add, ModifyDN.
479         * Result code type: Specific (Attribute)
480         */
481        CONSTRAINT_VIOLATION( 19 ),
482    
483        /**
484         * This error should be returned by the server if the value specified by the
485         * client already exists within the attribute. Applicable operations:
486         * Modify, Add. Result code type: Specific (Attribute)
487         */
488        ATTRIBUTE_OR_VALUE_EXISTS( 20 ),
489    
490        /**
491         * This error should be returned by the server if the attribute syntax for
492         * the attribute value, specified as an argument of the operation, is
493         * unrecognized or invalid. Applicable operations: Modify, Add. Result code
494         * type: Specific (Attribute)
495         */
496        INVALID_ATTRIBUTE_SYNTAX( 21 ),
497    
498        // ------------------------------------------------------------------------
499        // Name Problem Specific Error Codes:
500        //
501        // A name error reports a problem related to the distinguished name
502        // provided as an argument to an operation [X511, Section 12.5].
503        //
504        // For result codes of NO_SUCH_OBJECT, aliasProblem, invalidDNSyntax and
505        // aliasDereferencingProblem (see Section 5.2.2.3.7), the matchedDN
506        // field is set to the name of the lowest entry (object or alias) in the
507        // directory that was matched. If no aliases were dereferenced while
508        // attempting to locate the entry, this will be a truncated form of the
509        // name provided, or if aliases were dereferenced, of the resulting
510        // name, as defined in section 12.5 of X.511 [X511]. The matchedDN field
511        // is to be set to a zero length string with all other result codes
512        // [RFC2251, Section 4.1.10].
513        // ------------------------------------------------------------------------
514    
515        /**
516         * This error should only be returned if the target object cannot be found.
517         * For example, in a search operation if the search base can not be located
518         * in the DSA the server should return NO_SUCH_OBJECT. If, however, the search
519         * base is found but does not match the search filter, success, with no
520         * resultant objects, should be returned instead of NO_SUCH_OBJECT. If the
521         * LDAP server is a front end for an X.500 DSA then NO_SUCH_OBJECT may also be
522         * returned if discloseOnError is not granted for an entry and the client
523         * does not have permission to view or modify the entry. Applicable
524         * operations: all except for Bind. Result code type: Specific (Name)
525         */
526        NO_SUCH_OBJECT( 32 ),
527    
528        /**
529         * An alias has been dereferenced which names no object [X511, Section 12.5]
530         * Applicable operations: Search. Result code type: Specific (Name)
531         */
532        ALIAS_PROBLEM( 33 ),
533    
534        /**
535         * This error should be returned by the server if the DN syntax is
536         * incorrect. It should not be returned if the DN is correctly formed but
537         * represents an entry which is not permitted by the structure rules at the
538         * DSA ; in this case namingViolation should be returned instead. Applicable
539         * operations: all. Result code type: Specific (Name)
540         */
541        INVALID_DN_SYNTAX( 34 ),
542        
543        // ------------------------------------------------------------------------
544        // Update Problem Specific Error Codes:
545        //
546        // An update error reports problems related to attempts to add, delete, or
547        // modify information in the DIB [X511, Section 12.9].
548        // ------------------------------------------------------------------------
549    
550        /**
551         * The attempted addition or modification would violate the structure rules
552         * of the DIT as defined in the directory schema and X.501. That is, it
553         * would place an entry as the subordinate of an alias entry, or in a region
554         * of the DIT not permitted to a member of its object class, or would define
555         * an RDN for an entry to include a forbidden attribute type [X511, Section
556         * 12.9]. Applicable operations: Add, ModifyDN. Result code type: Specific
557         * (Update)
558         */
559        NAMING_VIOLATION( 64 ),
560    
561        /**
562         * This error should be returned if the operation requested by the user
563         * would violate the objectClass requirements for the entry if carried out.
564         * On an add or modify operation this would result from trying to add an
565         * object class without a required attribute, or by trying to add an
566         * attribute which is not permitted by the current object class set in the
567         * entry. On a modify operation this may result from trying to remove a
568         * required attribute without removing the associated auxiliary object
569         * class, or by attempting to remove an object class while the attributes it
570         * permits are still present. Applicable operations: Add, Modify, ModifyDN.
571         * Result code type: Specific (Update)
572         */
573        OBJECT_CLASS_VIOLATION( 65 ),
574    
575        /**
576         * This error should be returned if the client attempts to perform an
577         * operation which is permitted only on leaf entries - e.g., if the client
578         * attempts to delete a non-leaf entry. If the directory does not permit
579         * ModifyDN for non-leaf entries then this error may be returned if the
580         * client attempts to change the DN of a non-leaf entry. (Note that 1988
581         * edition X.500 servers only permitted change of the RDN of an entry's DN
582         * [X.511, Section 11.4.1]). Applicable operations: Delete, ModifyDN. Result
583         * code type: Specific (Update)
584         */
585        NOT_ALLOWED_ON_NON_LEAF( 66 ),
586    
587        /**
588         * The attempted operation would affect the RDN (e.g., removal of an
589         * attribute which is a part of the RDN) [X511, Section 12.9]. If the client
590         * attempts to remove from an entry any of its distinguished values, those
591         * values which form the entry's relative distinguished name the server
592         * should return the error notAllowedOnRDN. [RFC2251, Section 4.6]
593         * Applicable operations: Modify. Result code type: Specific (Update)
594         */
595        NOT_ALLOWED_ON_RDN( 67 ),
596    
597        /**
598         * This error should be returned by the server when the client attempts to
599         * add an entry which already exists, or if the client attempts to rename an
600         * entry with the name of an entry which exists. Applicable operations: Add,
601         * ModifyDN. Result code type: Specific (Update)
602         */
603        ENTRY_ALREADY_EXISTS( 68 ),
604    
605        /**
606         * An operation attempted to modify an object class that should not be
607         * modified, e.g., the structural object class of an entry. Some servers may
608         * not permit object class modifications, especially modifications to the
609         * structural object class since this may change the entry entirely, name
610         * forms, structure rules etc. [X.511, Section 12.9]. Applicable operations:
611         * Modify. Result code type: Specific (Update)
612         */
613        OBJECT_CLASS_MODS_PROHIBITED( 69 ),
614    
615        /**
616         * This error code should be returned to indicate that the operation could
617         * not be performed since it affects more than one DSA. This error code is
618         * new for LDAPv3. X.500 restricts the ModifyDN operation to only affect
619         * entries that are contained within a single server. If the LDAP server is
620         * mapped onto DAP, then this restriction will apply, and the resultCode
621         * affectsMultipleDSAs will be returned if this error occurred. In general
622         * clients MUST NOT expect to be able to perform arbitrary movements of
623         * entries and subtrees between servers [RFC2251, Section 4.9]. Applicable
624         * operations: ModifyDN. Result code type: Specific (Update)
625         */
626        AFFECTS_MULTIPLE_DSAS( 71 ),
627    
628        // ------------------------------------------------------------------------
629        // General Error Codes:
630        //
631        // A general error code typically specifies an error condition for which
632        // there is no suitable specific error code. If the server can return an
633        // error, which is more specific than the following general errors, then
634        // the specific error should be returned instead.
635        // ------------------------------------------------------------------------
636    
637        /**
638         * This error code should be returned only if no other error code is
639         * suitable. Use of this error code should be avoided if possible. Details
640         * of the error should be provided in the error message. Applicable
641         * operations: all. Result code type: General
642         */
643        OTHER( 80 ),
644        
645        /**
646         * This error code is returned when an operation has been canceled using
647         * the Cancel extended operation. 
648         */
649        CANCELED( 118 ),
650        
651        
652        /**
653         * This error code is returned if the server has no knowledge of
654         * the operation requested for cancelation.
655         */
656        NO_SUCH_OPERATION( 119 ),
657        
658        
659        /**
660         * The tooLate resultCode is returned to indicate that it is too late to
661         * cancel the outstanding operation.  For example, the server may return
662         * tooLate for a request to cancel an outstanding modify operation which
663         * has already committed updates to the underlying data store.
664         */
665        TOO_LATE( 120 ),
666        
667        /**
668         * The cannotCancel resultCode is returned if the identified operation
669         * does not support cancelation or the cancel operation could not be
670         * performed.  The following classes of operations are not cancelable:
671         *
672         * -  operations which have no response,
673         *
674         * -  operations which create, alter, or destroy authentication and/or
675         *    authorization associations,
676         *
677         * -  operations which establish, alter, or tear-down security services,
678         *    and
679         *
680         * -  operations which abandon or cancel other operations.
681         */
682        CANNOT_CANCEL( 121 ),
683        
684        /**
685         * A unknown result code to cover all the other cases
686         */
687        // -- 15 unused --
688        // -- 22-31 unused --
689        // -- 35 reserved for undefined isLeaf --
690        // -- 37-47 unused --
691        // -- 55-63 unused --
692        // -- 70 reserved for CLDAP --
693        // -- 72-79 unused --
694        // -- 81-90 reserved for APIs --
695        UNKNOWN( 122 );
696        
697        /** Stores the integer value of each element of the enumeration */
698        private int value;
699    
700        /**
701         * Private construct so no other instances can be created other than the
702         * public static constants in this class.
703         * 
704         * @param value the integer value of the enumeration.
705         */
706        private ResultCodeEnum( int value )
707        {
708            this.value = value;
709        }
710        
711        /**
712         * @return The value associated with the current element.
713         */
714        public int getValue()
715        {
716            return value;
717        }
718        
719        public static final Set<ResultCodeEnum> EMPTY_RESULT_CODE_SET = new HashSet<ResultCodeEnum>();
720        
721        
722        // ------------------------------------------------------------------------
723        // Error Codes Grouped Into Categories & Static Accessors
724        // ------------------------------------------------------------------------
725    
726        /**
727         * This array holds the set of general error codes. General error codes are
728         * typically returned only when no suitable specific error exists. Specific
729         * error codes are meant to capture situations that are specific to the
730         * requested operation. A general error code typically specifies an error
731         * condition for which there is no suitable specific error code. If the
732         * server can return an error, which is more specific than the following
733         * general errors, then the specific error should be returned instead. This
734         * array only contains the OTHER error code at the present time. The set
735         * contains:
736         * <ul>
737         * <li><a href="OTHER">OTHER</a></li>
738         * </ul>
739         */
740        public static final Set<ResultCodeEnum> GENERAL_CODES = Collections.singleton( OTHER );
741    
742        /**
743         * Five result codes that may be returned in LDAPResult are not used to
744         * indicate an error. The first three codes, indicate to the client that no
745         * further action is required in order to satisfy their request. In
746         * contrast, the last two errors require further action by the client in
747         * order to complete their original operation request. The set contains:
748         * <ul>
749         * <li><a href="#SUCCESS">SUCCESS</a></li>
750         * <li><a href="#COMPARETRUE">COMPARETRUE</a></li>
751         * <li><a href="#COMPAREFALSE">COMPAREFALSE</a></li>
752         * <li><a href="#REFERRAL">REFERRAL</a></li>
753         * <li><a href="#SASL_BIND_IN_PROGRESS">SASL_BIND_IN_PROGRESS</a></li>
754         * </ul>
755         */
756        public static final Set<ResultCodeEnum> NON_ERRONEOUS_CODES;
757        
758        static
759        {
760            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
761            set.add( ResultCodeEnum.SUCCESS );
762            set.add( ResultCodeEnum.COMPARE_TRUE );
763            set.add( ResultCodeEnum.COMPARE_FALSE );
764            set.add( ResultCodeEnum.REFERRAL );
765            set.add( ResultCodeEnum.SASL_BIND_IN_PROGRESS );
766            set.add( ResultCodeEnum.CANCELED );
767            NON_ERRONEOUS_CODES = Collections.unmodifiableSet( set );
768        }
769    
770        /**
771         * Contains the set of error codes associated with attribute problems. An
772         * attribute error reports a problem related to an attribute specified by
773         * the client in their request message. The set contains:
774         * <ul>
775         * <li><a href="#NO_SUCH_ATTRIBUTE">NO_SUCH_ATTRIBUTE</a></li>
776         * <li><a href="#UNDEFINED_ATTRIBUTE_TYPE">UNDEFINED_ATTRIBUTE_TYPE</a></li>
777         * <li><a href="#INAPPROPRIATE_MATCHING">INAPPROPRIATE_MATCHING</a></li>
778         * <li><a href="#CONSTRAINT_VIOLATION">CONSTRAINT_VIOLATION</a></li>
779         * <li><a href="#ATTRIBUTE_OR_VALUE_EXISTS">ATTRIBUTE_OR_VALUE_EXISTS</a></li>
780         * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">INVALID_ATTRIBUTE_SYNTAX</a></li>
781         * </ul>
782         */
783        public static final Set<ResultCodeEnum> ATTRIBUTE_CODES;
784        
785        static
786        {
787            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
788            set.add( ResultCodeEnum.NO_SUCH_ATTRIBUTE );
789            set.add( ResultCodeEnum.UNDEFINED_ATTRIBUTE_TYPE );
790            set.add( ResultCodeEnum.INAPPROPRIATE_MATCHING );
791            set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
792            set.add( ResultCodeEnum.ATTRIBUTE_OR_VALUE_EXISTS );
793            set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
794            ATTRIBUTE_CODES = Collections.unmodifiableSet( set );
795        }
796    
797        /**
798         * Stores the set of error codes associated with name problems. A name error
799         * reports a problem related to the distinguished name provided as an
800         * argument to an operation [X511, Section 12.5]. For result codes of
801         * NO_SUCH_OBJECT, aliasProblem, invalidDNSyntax and
802         * aliasDereferencingProblem, the matchedDN field is set to the name of the
803         * lowest entry (object or alias) in the directory that was matched. If no
804         * aliases were dereferenced while attempting to locate the entry, this will
805         * be a truncated form of the name provided, or if aliases were dereferenced
806         * of the resulting name, as defined in section 12.5 of X.511 [X511]. The
807         * matchedDN field is to be set to a zero length string with all other
808         * result codes [RFC2251, Section 4.1.10]. The set contains:
809         * <ul>
810         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
811         * <li><a href="#ALIAS_PROBLEM">ALIAS_PROBLEM</a></li>
812         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
813         * </ul>
814         */
815        public static final Set<ResultCodeEnum> NAME_CODES;
816        
817        static
818        {
819            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
820            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
821            set.add( ResultCodeEnum.ALIAS_PROBLEM );
822            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
823            NAME_CODES = Collections.unmodifiableSet( set );
824        }
825    
826        /**
827         * Stores all the result codes associated with security related problems. A
828         * security error reports a problem in carrying out an operation for
829         * security reasons [X511, Section 12.7]. The set contains:
830         * <ul>
831         * <li><a href="#INVALID_CREDENTIALS">INVALID_CREDENTIALS</a></li>
832         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
833         * <li><a href="#AUTH_METHOD_NOT_SUPPORTED">AUTH_METHOD_NOT_SUPPORTED</a></li>
834         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
835         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
836         * <li><a href="#ALIAS_DEREFERENCING_PROBLEM">ALIAS_DEREFERENCING_PROBLEM</a></li>
837         * <li><a href="#INAPPROPRIATE_AUTHENTICATION">INAPPROPRIATE_AUTHENTICATION</a></li>
838         * </ul>
839         */
840        public static final Set<ResultCodeEnum> SECURITY_CODES;
841        
842        static
843        {
844            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
845            set.add( ResultCodeEnum.INVALID_CREDENTIALS );
846            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
847            set.add( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
848            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
849            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
850            set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
851            set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
852            SECURITY_CODES = Collections.unmodifiableSet( set );
853        }
854    
855        /**
856         * A service error reports a problem related to the provision of the service
857         * [X511, Section 12.8]. This set stores all error codes related to service
858         * problems. The set contains:
859         * <ul>
860         * <li><a href="#BUSY">BUSY</a></li>
861         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
862         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
863         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
864         * <li><a href="#OPERATIONSERROR">OPERATIONSERROR</a></li>
865         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
866         * <li><a href="#SIZE_LIMIT_EXCEEDED">SIZE_LIMIT_EXCEEDED</a></li>
867         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
868         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
869         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
870         * </ul>
871         */
872        public static final Set<ResultCodeEnum> SERVICE_CODES;
873        
874        static
875        {
876            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
877            set.add( ResultCodeEnum.BUSY );
878            set.add( ResultCodeEnum.LOOP_DETECT );
879            set.add( ResultCodeEnum.UNAVAILABLE );
880            set.add( ResultCodeEnum.PROTOCOL_ERROR );
881            set.add( ResultCodeEnum.OPERATIONS_ERROR );
882            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
883            set.add( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
884            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
885            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
886            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
887            set.add( ResultCodeEnum.CANNOT_CANCEL );
888            set.add( ResultCodeEnum.TOO_LATE );
889            set.add( ResultCodeEnum.NO_SUCH_OPERATION );
890            SERVICE_CODES = Collections.unmodifiableSet( set );
891        }
892    
893        /**
894         * An update error reports problems related to attempts to add, delete, or
895         * modify information in the DIB [X511, Section 12.9]. This set contains the
896         * category of update errors.
897         * <ul>
898         * <li><a href="#NAMING_VIOLATION">NAMING_VIOLATION</a></li>
899         * <li><a href="#OBJECT_CLASS_VIOLATION">OBJECT_CLASS_VIOLATION</a></li>
900         * <li><a href="#NOT_ALLOWED_ON_NON_LEAF">NOT_ALLOWED_ON_NON_LEAF</a></li>
901         * <li><a href="#NOT_ALLOWED_ON_RDN">NOT_ALLOWED_ON_RDN</a></li>
902         * <li><a href="#ENTRY_ALREADY_EXISTS">ENTRY_ALREADY_EXISTS</a></li>
903         * <li><a href="#OBJECT_CLASS_MODS_PROHIBITED">OBJECT_CLASS_MODS_PROHIBITED</a></li>
904         * <li><a href="#AFFECTS_MULTIPLE_DSAS">AFFECTS_MULTIPLE_DSAS</a></li>
905         * </ul>
906         */
907        public static final Set<ResultCodeEnum> UPDATE_CODES;
908        
909        static
910        {
911            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
912            set.add( ResultCodeEnum.NAMING_VIOLATION );
913            set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
914            set.add( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF );
915            set.add( ResultCodeEnum.NOT_ALLOWED_ON_RDN );
916            set.add( ResultCodeEnum.ENTRY_ALREADY_EXISTS );
917            set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
918            set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
919            UPDATE_CODES = Collections.unmodifiableSet( set );
920        }
921    
922        // ------------------------------------------------------------------------
923        // Result Codes Categorized by Request Type
924        // ------------------------------------------------------------------------
925    
926        /**
927         * A set of result code enumerations common to all operations. The set
928         * contains:
929         * <ul>
930         * <li><a href="#BUSY">BUSY</a></li>
931         * <li><a href="#OTHER">OTHER</a></li>
932         * <li><a href="#REFERRAL">REFERRAL</a></li>
933         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
934         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
935         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
936         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
937         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
938         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
939         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
940         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
941         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
942         * </ul>
943         */
944        public static final Set<ResultCodeEnum> COMMON_CODES;
945        static
946        {
947            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
948            set.add( ResultCodeEnum.BUSY );
949            set.add( ResultCodeEnum.OTHER );
950            set.add( ResultCodeEnum.REFERRAL );
951            set.add( ResultCodeEnum.LOOP_DETECT );
952            set.add( ResultCodeEnum.UNAVAILABLE );
953            set.add( ResultCodeEnum.PROTOCOL_ERROR );
954            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
955            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
956            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
957            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
958            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
959            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
960            COMMON_CODES = Collections.unmodifiableSet( set );
961        }
962    
963        /**
964         * A set of result code enumerations that may result from bind operations.
965         * The set contains:
966         * <ul>
967         * <li><a href="#BUSY">BUSY</a></li>
968         * <li><a href="#OTHER">OTHER</a></li>
969         * <li><a href="#SUCCESS">SUCCESS</a></li>
970         * <li><a href="#REFERRAL">REFERRAL</a></li>
971         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
972         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
973         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
974         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
975         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
976         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
977         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
978         * <li><a href="#SASL_BIND_IN_PROGRESS">SASL_BIND_IN_PROGRESS</a></li>
979         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
980         * <li><a href="#INVALID_CREDENTIALS">INVALID_CREDENTIALS</a></li>
981         * <li><a href="#AUTH_METHOD_NOT_SUPPORTED">AUTH_METHOD_NOT_SUPPORTED</a></li>
982         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
983         * <li><a href="#INAPPROPRIATE_AUTHENTICATION">INAPPROPRIATE_AUTHENTICATION</a></li>
984         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
985         * </ul>
986         */
987        public static final Set<ResultCodeEnum> BIND_CODES;
988        static
989        {
990            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
991            set.add( ResultCodeEnum.BUSY );
992            set.add( ResultCodeEnum.OTHER );
993            set.add( ResultCodeEnum.SUCCESS );
994            set.add( ResultCodeEnum.REFERRAL );
995            set.add( ResultCodeEnum.LOOP_DETECT );
996            set.add( ResultCodeEnum.UNAVAILABLE );
997            set.add( ResultCodeEnum.PROTOCOL_ERROR );
998            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
999            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1000            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1001            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1002            set.add( ResultCodeEnum.SASL_BIND_IN_PROGRESS );
1003            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1004            set.add( ResultCodeEnum.INVALID_CREDENTIALS );
1005            set.add( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
1006            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1007            set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
1008            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1009            set.add( ResultCodeEnum.CANCELED );
1010            BIND_CODES = Collections.unmodifiableSet( set );
1011        }
1012    
1013        /**
1014         * A set of result code enumerations that may result from search operations.
1015         * The set contains:
1016         * <ul>
1017         * <li><a href="#BUSY">BUSY</a></li>
1018         * <li><a href="#OTHER">OTHER</a></li>
1019         * <li><a href="#SUCCESS">SUCCESS</a></li>
1020         * <li><a href="#REFERRAL">REFERRAL</a></li>
1021         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1022         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1023         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1024         * <li><a href="#ALIAS_PROBLEM">ALIAS_PROBLEM</a></li>
1025         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1026         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1027         * <li><a href="#SIZE_LIMIT_EXCEEDED">SIZE_LIMIT_EXCEEDED</a></li>
1028         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1029         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1030         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1031         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1032         * <li><a href="#INAPPROPRIATE_MATCHING">INAPPROPRIATE_MATCHING</a></li>
1033         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1034         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1035         * <li><a href="#ALIAS_DEREFERENCING_PROBLEM">ALIAS_DEREFERENCING_PROBLEM</a></li>
1036         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1037         * </ul>
1038         */
1039        public static final Set<ResultCodeEnum> SEARCH_CODES;
1040        static
1041        {
1042            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1043            set.add( ResultCodeEnum.BUSY );
1044            set.add( ResultCodeEnum.OTHER );
1045            set.add( ResultCodeEnum.SUCCESS );
1046            set.add( ResultCodeEnum.REFERRAL );
1047            set.add( ResultCodeEnum.LOOP_DETECT );
1048            set.add( ResultCodeEnum.UNAVAILABLE );
1049            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1050            set.add( ResultCodeEnum.ALIAS_PROBLEM );
1051            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1052            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1053            set.add( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
1054            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1055            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1056            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1057            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1058            set.add( ResultCodeEnum.INAPPROPRIATE_MATCHING );
1059            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1060            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1061            set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
1062            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1063            set.add( ResultCodeEnum.CANCELED );
1064            SEARCH_CODES = Collections.unmodifiableSet( set );
1065        }
1066    
1067        /**
1068         * A set of result code enumerations that may result from modify operations.
1069         * The set contains:
1070         * <ul>
1071         * <li><a href="#BUSY">BUSY</a></li>
1072         * <li><a href="#OTHER">OTHER</a></li>
1073         * <li><a href="#SUCCESS">SUCCESS</a></li>
1074         * <li><a href="#REFERRAL">REFERRAL</a></li>
1075         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1076         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1077         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1078         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1079         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1080         * <li><a href="#NOT_ALLOWED_ON_RDN">NOT_ALLOWED_ON_RDN</a></li>
1081         * <li><a href="#NO_SUCH_ATTRIBUTE">NO_SUCH_ATTRIBUTE</a></li>
1082         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1083         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1084         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1085         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1086         * <li><a href="#CONSTRAINT_VIOLATION">CONSTRAINT_VIOLATION</a></li>
1087         * <li><a href="#OBJECT_CLASS_VIOLATION">OBJECT_CLASS_VIOLATION</a></li>
1088         * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">INVALID_ATTRIBUTE_SYNTAX</a></li>
1089         * <li><a href="#UNDEFINED_ATTRIBUTE_TYPE">UNDEFINED_ATTRIBUTE_TYPE</a></li>
1090         * <li><a href="#ATTRIBUTE_OR_VALUE_EXISTS">ATTRIBUTE_OR_VALUE_EXISTS</a></li>
1091         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1092         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1093         * <li><a href="#OBJECT_CLASS_MODS_PROHIBITED">OBJECT_CLASS_MODS_PROHIBITED</a></li>
1094         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1095         * </ul>
1096         */
1097        public static final Set<ResultCodeEnum> MODIFY_CODES;
1098        static
1099        {
1100            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1101            set.add( ResultCodeEnum.BUSY );
1102            set.add( ResultCodeEnum.OTHER );
1103            set.add( ResultCodeEnum.SUCCESS );
1104            set.add( ResultCodeEnum.REFERRAL );
1105            set.add( ResultCodeEnum.LOOP_DETECT );
1106            set.add( ResultCodeEnum.UNAVAILABLE );
1107            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1108            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1109            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1110            set.add( ResultCodeEnum.NOT_ALLOWED_ON_RDN );
1111            set.add( ResultCodeEnum.NO_SUCH_ATTRIBUTE );
1112            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1113            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1114            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1115            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1116            set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
1117            set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
1118            set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
1119            set.add( ResultCodeEnum.UNDEFINED_ATTRIBUTE_TYPE );
1120            set.add( ResultCodeEnum.ATTRIBUTE_OR_VALUE_EXISTS );
1121            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1122            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1123            set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
1124            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1125            set.add( ResultCodeEnum.CANCELED );
1126            MODIFY_CODES = Collections.unmodifiableSet( set );
1127        }
1128    
1129        /**
1130         * A set of result code enumerations that may result from add operations.
1131         * The set contains:
1132         * <ul>
1133         * <li><a href="#BUSY">BUSY</a></li>
1134         * <li><a href="#OTHER">OTHER</a></li>
1135         * <li><a href="#SUCCESS">SUCCESS</a></li>
1136         * <li><a href="#REFERRAL">REFERRAL</a></li>
1137         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1138         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1139         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1140         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1141         * <li><a href="#NAMING_VIOLATION">NAMING_VIOLATION</a></li>
1142         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1143         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1144         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1145         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1146         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1147         * <li><a href="#ENTRY_ALREADY_EXISTS">ENTRY_ALREADY_EXISTS</a></li>
1148         * <li><a href="#CONSTRAINT_VIOLATION">CONSTRAINT_VIOLATION</a></li>
1149         * <li><a href="#OBJECT_CLASS_VIOLATION">OBJECT_CLASS_VIOLATION</a></li>
1150         * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">INVALID_ATTRIBUTE_SYNTAX</a></li>
1151         * <li><a href="#ATTRIBUTE_OR_VALUE_EXISTS">ATTRIBUTE_OR_VALUE_EXISTS</a></li>
1152         * <li><a href="#UNDEFINED_ATTRIBUTE_TYPE">UNDEFINED_ATTRIBUTE_TYPE</a></li>
1153         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1154         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1155         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1156         * </ul>
1157         */
1158        public static final Set<ResultCodeEnum> ADD_CODES;
1159        static
1160        {
1161            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1162            set.add( ResultCodeEnum.BUSY );
1163            set.add( ResultCodeEnum.OTHER );
1164            set.add( ResultCodeEnum.SUCCESS );
1165            set.add( ResultCodeEnum.REFERRAL );
1166            set.add( ResultCodeEnum.LOOP_DETECT );
1167            set.add( ResultCodeEnum.UNAVAILABLE );
1168            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1169            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1170            set.add( ResultCodeEnum.NAMING_VIOLATION );
1171            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1172            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1173            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1174            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1175            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1176            set.add( ResultCodeEnum.ENTRY_ALREADY_EXISTS );
1177            set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
1178            set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
1179            set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
1180            set.add( ResultCodeEnum.ATTRIBUTE_OR_VALUE_EXISTS );
1181            set.add( ResultCodeEnum.UNDEFINED_ATTRIBUTE_TYPE );
1182            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1183            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1184            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1185            set.add( ResultCodeEnum.CANCELED );
1186            ADD_CODES = Collections.unmodifiableSet( set );
1187        }
1188    
1189        /**
1190         * A set of result code enumerations that may result from delete operations.
1191         * The set may contain:
1192         * <ul>
1193         * <li><a href="#BUSY">BUSY</a></li>
1194         * <li><a href="#OTHER">OTHER</a></li>
1195         * <li><a href="#SUCCESS">SUCCESS</a></li>
1196         * <li><a href="#REFERRAL">REFERRAL</a></li>
1197         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1198         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1199         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1200         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1201         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1202         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1203         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1204         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1205         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1206         * <li><a href="#NOT_ALLOWED_ON_NON_LEAF">NOT_ALLOWED_ON_NON_LEAF</a></li>
1207         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1208         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1209         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1210         * </ul>
1211         */
1212        public static final Set<ResultCodeEnum> DELETE_CODES;
1213        static
1214        {
1215            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1216            set.add( ResultCodeEnum.BUSY );
1217            set.add( ResultCodeEnum.OTHER );
1218            set.add( ResultCodeEnum.SUCCESS );
1219            set.add( ResultCodeEnum.REFERRAL );
1220            set.add( ResultCodeEnum.LOOP_DETECT );
1221            set.add( ResultCodeEnum.UNAVAILABLE );
1222            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1223            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1224            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1225            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1226            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1227            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1228            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1229            set.add( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF );
1230            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1231            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1232            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1233            set.add( ResultCodeEnum.CANCELED );
1234            DELETE_CODES = Collections.unmodifiableSet( set );
1235        }
1236    
1237        /**
1238         * A set of result code enumerations resulting from modifyDn operations. The
1239         * set contains:
1240         * <ul>
1241         * <li><a href="#BUSY">BUSY</a></li>
1242         * <li><a href="#OTHER">OTHER</a></li>
1243         * <li><a href="#SUCCESS">SUCCESS</a></li>
1244         * <li><a href="#REFERRAL">REFERRAL</a></li>
1245         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1246         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1247         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1248         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1249         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1250         * <li><a href="#NAMING_VIOLATION">NAMING_VIOLATION</a></li>
1251         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1252         * <li><a href="#ENTRY_ALREADY_EXISTS">ENTRY_ALREADY_EXISTS</a></li>
1253         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1254         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1255         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1256         * <li><a href="#NOT_ALLOWED_ON_NON_LEAF">NOT_ALLOWED_ON_NON_LEAF</a></li>
1257         * <li><a href="#AFFECTS_MULTIPLE_DSAS">AFFECTS_MULTIPLE_DSAS</a></li>
1258         * <li><a href="#CONSTRAINT_VIOLATION">CONSTRAINT_VIOLATION</a></li>
1259         * <li><a href="#OBJECT_CLASS_VIOLATION">OBJECT_CLASS_VIOLATION</a></li>
1260         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1261         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1262         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1263         * </ul>
1264         */
1265        public static final Set<ResultCodeEnum> MODIFYDN_CODES;
1266        static
1267        {
1268            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1269            set.add( ResultCodeEnum.BUSY );
1270            set.add( ResultCodeEnum.OTHER );
1271            set.add( ResultCodeEnum.SUCCESS );
1272            set.add( ResultCodeEnum.REFERRAL );
1273            set.add( ResultCodeEnum.LOOP_DETECT );
1274            set.add( ResultCodeEnum.UNAVAILABLE );
1275            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1276            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1277            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1278            set.add( ResultCodeEnum.NAMING_VIOLATION );
1279            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1280            set.add( ResultCodeEnum.ENTRY_ALREADY_EXISTS );
1281            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1282            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1283            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1284            set.add( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF );
1285            set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
1286            set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
1287            set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
1288            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1289            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1290            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1291            set.add( ResultCodeEnum.CANCELED );
1292            MODIFYDN_CODES = Collections.unmodifiableSet( set );
1293        }
1294    
1295        /**
1296         * A set of result code enumerations that may result from compare
1297         * operations. The set contains:
1298         * <ul>
1299         * <li><a href="#OPERATIONSERROR">OPERATIONSERROR</a></li>
1300         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1301         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1302         * <li><a href="#COMPAREFALSE">COMPAREFALSE</a></li>
1303         * <li><a href="#COMPARETRUE">COMPARETRUE</a></li>
1304         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1305         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1306         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1307         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1308         * <li><a href="#NO_SUCH_ATTRIBUTE">NO_SUCH_ATTRIBUTE</a></li>
1309         * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">INVALID_ATTRIBUTE_SYNTAX</a></li>
1310         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1311         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1312         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1313         * <li><a href="#BUSY">BUSY</a></li>
1314         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1315         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1316         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1317         * <li><a href="#REFERRAL">REFERRAL</a></li>
1318         * <li><a href="#OTHER">OTHER</a></li>
1319         * </ul>
1320         */
1321        public static final Set<ResultCodeEnum> COMPARE_CODES;
1322        static
1323        {
1324            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1325            set.add( ResultCodeEnum.OPERATIONS_ERROR );
1326            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1327            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1328            set.add( ResultCodeEnum.COMPARE_FALSE );
1329            set.add( ResultCodeEnum.COMPARE_TRUE );
1330            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1331            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1332            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1333            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1334            set.add( ResultCodeEnum.NO_SUCH_ATTRIBUTE );
1335            set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
1336            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1337            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1338            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1339            set.add( ResultCodeEnum.BUSY );
1340            set.add( ResultCodeEnum.UNAVAILABLE );
1341            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1342            set.add( ResultCodeEnum.LOOP_DETECT );
1343            set.add( ResultCodeEnum.REFERRAL );
1344            set.add( ResultCodeEnum.OTHER );
1345            set.add( ResultCodeEnum.CANCELED );
1346            COMPARE_CODES = Collections.unmodifiableSet( set );
1347        }
1348    
1349        /**
1350         * A set of result code enumerations that could result from extended
1351         * operations. The set contains:
1352         * <ul>
1353         * <li></li>
1354         * <li><a href="#SUCCESS">SUCCESS</a></li>
1355         * <li><a href="#OPERATIONSERROR">OPERATIONSERROR</a></li>
1356         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1357         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1358         * <li><a href="#SIZE_LIMIT_EXCEEDED">SIZE_LIMIT_EXCEEDED</a></li>
1359         * <li><a href="#COMPAREFALSE">COMPAREFALSE</a></li>
1360         * <li><a href="#COMPARETRUE">COMPARETRUE</a></li>
1361         * <li><a href="#AUTH_METHOD_NOT_SUPPORTED">AUTH_METHOD_NOT_SUPPORTED</a></li>
1362         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1363         * <li><a href="#REFERRAL">REFERRAL</a></li>
1364         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1365         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1366         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1367         * <li><a href="#SASL_BIND_IN_PROGRESS">SASL_BIND_IN_PROGRESS</a></li>
1368         * <li><a href="#NO_SUCH_ATTRIBUTE">NO_SUCH_ATTRIBUTE</a></li>
1369         * <li><a href="#UNDEFINED_ATTRIBUTE_TYPE">UNDEFINED_ATTRIBUTE_TYPE</a></li>
1370         * <li><a href="#INAPPROPRIATE_MATCHING">INAPPROPRIATE_MATCHING</a></li>
1371         * <li><a href="#CONSTRAINT_VIOLATION">CONSTRAINT_VIOLATION</a></li>
1372         * <li><a href="#ATTRIBUTE_OR_VALUE_EXISTS">ATTRIBUTE_OR_VALUE_EXISTS</a></li>
1373         * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">INVALID_ATTRIBUTE_SYNTAX</a></li>
1374         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1375         * <li><a href="#ALIAS_PROBLEM">ALIAS_PROBLEM</a></li>
1376         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1377         * <li><a href="#ALIAS_DEREFERENCING_PROBLEM">ALIAS_DEREFERENCING_PROBLEM</a></li>
1378         * <li><a href="#INAPPROPRIATE_AUTHENTICATION">INAPPROPRIATE_AUTHENTICATION</a></li>
1379         * <li><a href="#INVALID_CREDENTIALS">INVALID_CREDENTIALS</a></li>
1380         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1381         * <li><a href="#BUSY">BUSY</a></li>
1382         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1383         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1384         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1385         * <li><a href="#NAMING_VIOLATION">NAMING_VIOLATION</a></li>
1386         * <li><a href="#OBJECT_CLASS_VIOLATION">OBJECT_CLASS_VIOLATION</a></li>
1387         * <li><a href="#NOT_ALLOWED_ON_NON_LEAF">NOT_ALLOWED_ON_NON_LEAF</a></li>
1388         * <li><a href="#NOT_ALLOWED_ON_RDN">NOT_ALLOWED_ON_RDN</a></li>
1389         * <li><a href="#ENTRY_ALREADY_EXISTS">ENTRY_ALREADY_EXISTS</a></li>
1390         * <li><a href="#OBJECT_CLASS_MODS_PROHIBITED">OBJECT_CLASS_MODS_PROHIBITED</a></li>
1391         * <li><a href="#AFFECTS_MULTIPLE_DSAS">AFFECTS_MULTIPLE_DSAS</a></li>
1392         * <li><a href="#OTHER">OTHER</a></li>
1393         * </ul>
1394         */
1395        public static final Set<ResultCodeEnum> EXTENDED_CODES;
1396        static
1397        {
1398            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1399            set.add( ResultCodeEnum.SUCCESS );
1400            set.add( ResultCodeEnum.OPERATIONS_ERROR );
1401            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1402            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1403            set.add( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
1404            set.add( ResultCodeEnum.COMPARE_FALSE );
1405            set.add( ResultCodeEnum.COMPARE_TRUE );
1406            set.add( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
1407            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1408            set.add( ResultCodeEnum.REFERRAL );
1409            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1410            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1411            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1412            set.add( ResultCodeEnum.SASL_BIND_IN_PROGRESS );
1413            set.add( ResultCodeEnum.NO_SUCH_ATTRIBUTE );
1414            set.add( ResultCodeEnum.UNDEFINED_ATTRIBUTE_TYPE );
1415            set.add( ResultCodeEnum.INAPPROPRIATE_MATCHING );
1416            set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
1417            set.add( ResultCodeEnum.ATTRIBUTE_OR_VALUE_EXISTS );
1418            set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
1419            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1420            set.add( ResultCodeEnum.ALIAS_PROBLEM );
1421            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1422            set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
1423            set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
1424            set.add( ResultCodeEnum.INVALID_CREDENTIALS );
1425            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1426            set.add( ResultCodeEnum.BUSY );
1427            set.add( ResultCodeEnum.UNAVAILABLE );
1428            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1429            set.add( ResultCodeEnum.LOOP_DETECT );
1430            set.add( ResultCodeEnum.NAMING_VIOLATION );
1431            set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
1432            set.add( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF );
1433            set.add( ResultCodeEnum.NOT_ALLOWED_ON_RDN );
1434            set.add( ResultCodeEnum.ENTRY_ALREADY_EXISTS );
1435            set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
1436            set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
1437            set.add( ResultCodeEnum.OTHER );
1438            set.add( ResultCodeEnum.CANCELED );
1439            EXTENDED_CODES = Collections.unmodifiableSet( set );
1440        }
1441    
1442        // ------------------------------------------------------------------------
1443        // All Result Codes
1444        // ------------------------------------------------------------------------
1445    
1446        /**
1447         * Set of all result code enumerations. The set contains:
1448         * <ul>
1449         * <li><a href="#SUCCESS">SUCCESS</a></li>
1450         * <li><a href="#OPERATIONSERROR">OPERATIONSERROR</a></li>
1451         * <li><a href="#PROTOCOL_ERROR">PROTOCOL_ERROR</a></li>
1452         * <li><a href="#TIME_LIMIT_EXCEEDED">TIME_LIMIT_EXCEEDED</a></li>
1453         * <li><a href="#SIZE_LIMIT_EXCEEDED">SIZE_LIMIT_EXCEEDED</a></li>
1454         * <li><a href="#COMPAREFALSE">COMPAREFALSE</a></li>
1455         * <li><a href="#COMPARETRUE">COMPARETRUE</a></li>
1456         * <li><a href="#AUTH_METHOD_NOT_SUPPORTED">AUTH_METHOD_NOT_SUPPORTED</a></li>
1457         * <li><a href="#STRONG_AUTH_REQUIRED">STRONG_AUTH_REQUIRED</a></li>
1458         * <li><a href="#PARTIAL_RESULTS">PARTIAL_RESULTS</a></li>
1459         * <li><a href="#REFERRAL">REFERRAL</a></li>
1460         * <li><a href="#ADMIN_LIMIT_EXCEEDED">ADMIN_LIMIT_EXCEEDED</a></li>
1461         * <li><a href="#UNAVAILABLE_CRITICAL_EXTENSION">UNAVAILABLE_CRITICAL_EXTENSION</a></li>
1462         * <li><a href="#CONFIDENTIALITY_REQUIRED">CONFIDENTIALITY_REQUIRED</a></li>
1463         * <li><a href="#SASL_BIND_IN_PROGRESS">SASL_BIND_IN_PROGRESS</a></li>
1464         * <li><a href="#NO_SUCH_ATTRIBUTE">NO_SUCH_ATTRIBUTE</a></li>
1465         * <li><a href="#UNDEFINED_ATTRIBUTE_TYPE">UNDEFINED_ATTRIBUTE_TYPE</a></li>
1466         * <li><a href="#INAPPROPRIATE_MATCHING">INAPPROPRIATE_MATCHING</a></li>
1467         * <li><a href="#CONSTRAINT_VIOLATION">CONSTRAINT_VIOLATION</a></li>
1468         * <li><a href="#ATTRIBUTE_OR_VALUE_EXISTS">ATTRIBUTE_OR_VALUE_EXISTS</a></li>
1469         * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">INVALID_ATTRIBUTE_SYNTAX</a></li>
1470         * <li><a href="#NO_SUCH_OBJECT">NO_SUCH_OBJECT</a></li>
1471         * <li><a href="#ALIAS_PROBLEM">ALIAS_PROBLEM</a></li>
1472         * <li><a href="#INVALID_DN_SYNTAX">INVALID_DN_SYNTAX</a></li>
1473         * <li><a href="#ALIAS_DEREFERENCING_PROBLEM">ALIAS_DEREFERENCING_PROBLEM</a></li>
1474         * <li><a href="#INAPPROPRIATE_AUTHENTICATION">INAPPROPRIATE_AUTHENTICATION</a></li>
1475         * <li><a href="#INVALID_CREDENTIALS">INVALID_CREDENTIALS</a></li>
1476         * <li><a href="#INSUFFICIENT_ACCESS_RIGHTS">INSUFFICIENT_ACCESS_RIGHTS</a></li>
1477         * <li><a href="#BUSY">BUSY</a></li>
1478         * <li><a href="#UNAVAILABLE">UNAVAILABLE</a></li>
1479         * <li><a href="#UNWILLING_TO_PERFORM">UNWILLING_TO_PERFORM</a></li>
1480         * <li><a href="#LOOP_DETECT">LOOP_DETECT</a></li>
1481         * <li><a href="#NAMING_VIOLATION">NAMING_VIOLATION</a></li>
1482         * <li><a href="#OBJECT_CLASS_VIOLATION">OBJECT_CLASS_VIOLATION</a></li>
1483         * <li><a href="#NOT_ALLOWED_ON_NON_LEAF">NOT_ALLOWED_ON_NON_LEAF</a></li>
1484         * <li><a href="#NOT_ALLOWED_ON_RDN">NOT_ALLOWED_ON_RDN</a></li>
1485         * <li><a href="#ENTRY_ALREADY_EXISTS">ENTRY_ALREADY_EXISTS</a></li>
1486         * <li><a href="#OBJECT_CLASS_MODS_PROHIBITED">OBJECT_CLASS_MODS_PROHIBITED</a></li>
1487         * <li><a href="#AFFECTS_MULTIPLE_DSAS">AFFECTS_MULTIPLE_DSAS</a></li>
1488         * <li><a href="#OTHER">OTHER</a></li>
1489         * </ul>
1490         */
1491        public static final Set<ResultCodeEnum> ALL_CODES;
1492        static
1493        {
1494            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1495            set.add( ResultCodeEnum.SUCCESS );
1496            set.add( ResultCodeEnum.OPERATIONS_ERROR );
1497            set.add( ResultCodeEnum.PROTOCOL_ERROR );
1498            set.add( ResultCodeEnum.TIME_LIMIT_EXCEEDED );
1499            set.add( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
1500            set.add( ResultCodeEnum.COMPARE_FALSE );
1501            set.add( ResultCodeEnum.COMPARE_TRUE );
1502            set.add( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
1503            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1504            set.add( ResultCodeEnum.PARTIAL_RESULTS );
1505            set.add( ResultCodeEnum.REFERRAL );
1506            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1507            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1508            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1509            set.add( ResultCodeEnum.SASL_BIND_IN_PROGRESS );
1510            set.add( ResultCodeEnum.NO_SUCH_ATTRIBUTE );
1511            set.add( ResultCodeEnum.UNDEFINED_ATTRIBUTE_TYPE );
1512            set.add( ResultCodeEnum.INAPPROPRIATE_MATCHING );
1513            set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
1514            set.add( ResultCodeEnum.ATTRIBUTE_OR_VALUE_EXISTS );
1515            set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
1516            set.add( ResultCodeEnum.NO_SUCH_OBJECT );
1517            set.add( ResultCodeEnum.ALIAS_PROBLEM );
1518            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1519            set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
1520            set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
1521            set.add( ResultCodeEnum.INVALID_CREDENTIALS );
1522            set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
1523            set.add( ResultCodeEnum.BUSY );
1524            set.add( ResultCodeEnum.UNAVAILABLE );
1525            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1526            set.add( ResultCodeEnum.LOOP_DETECT );
1527            set.add( ResultCodeEnum.NAMING_VIOLATION );
1528            set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
1529            set.add( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF );
1530            set.add( ResultCodeEnum.NOT_ALLOWED_ON_RDN );
1531            set.add( ResultCodeEnum.ENTRY_ALREADY_EXISTS );
1532            set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
1533            set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
1534            set.add( ResultCodeEnum.OTHER );
1535            set.add( ResultCodeEnum.CANNOT_CANCEL );
1536            set.add( ResultCodeEnum.TOO_LATE );
1537            set.add( ResultCodeEnum.NO_SUCH_OPERATION );
1538            set.add( ResultCodeEnum.CANCELED );
1539            ALL_CODES = Collections.unmodifiableSet( set );
1540        }
1541    
1542        /**
1543         * @return The integer associated with the result code
1544         */
1545        public int getResultCode()
1546        {
1547            return value;
1548        }
1549        
1550        /**
1551         * @return The integer associated with the result code
1552         */
1553        public static ResultCodeEnum getResultCode( int value )
1554        {
1555            switch ( value )
1556            {
1557                case 0 : return SUCCESS;
1558                case 1 : return OPERATIONS_ERROR;
1559                case 2 : return PROTOCOL_ERROR;
1560                case 3 : return TIME_LIMIT_EXCEEDED;
1561                case 4 : return SIZE_LIMIT_EXCEEDED;
1562                case 5 : return COMPARE_FALSE;
1563                case 6 : return COMPARE_TRUE;
1564                case 7 : return AUTH_METHOD_NOT_SUPPORTED;
1565                case 8 : return STRONG_AUTH_REQUIRED;
1566                case 9 : return PARTIAL_RESULTS;
1567                case 10 : return REFERRAL;
1568                case 11 : return ADMIN_LIMIT_EXCEEDED;
1569                case 12 : return UNAVAILABLE_CRITICAL_EXTENSION;
1570                case 13 : return CONFIDENTIALITY_REQUIRED;
1571                case 14 : return SASL_BIND_IN_PROGRESS;
1572                case 16 : return NO_SUCH_ATTRIBUTE;
1573                case 17 : return UNDEFINED_ATTRIBUTE_TYPE;
1574                case 18 : return INAPPROPRIATE_MATCHING;
1575                case 19 : return CONSTRAINT_VIOLATION;
1576                case 20 : return ATTRIBUTE_OR_VALUE_EXISTS;
1577                case 21 : return INVALID_ATTRIBUTE_SYNTAX;
1578                case 32 : return NO_SUCH_OBJECT;
1579                case 33 : return ALIAS_PROBLEM;
1580                case 34 : return INVALID_DN_SYNTAX;
1581                case 35 : return UNKNOWN;
1582                case 36 : return ALIAS_DEREFERENCING_PROBLEM;
1583                case 48 : return INAPPROPRIATE_AUTHENTICATION; 
1584                case 49 : return INVALID_CREDENTIALS;
1585                case 50 : return INSUFFICIENT_ACCESS_RIGHTS;
1586                case 51 : return BUSY;
1587                case 52 : return UNAVAILABLE;
1588                case 53 : return UNWILLING_TO_PERFORM;
1589                case 54 : return LOOP_DETECT;
1590                case 64 : return NAMING_VIOLATION;
1591                case 65 : return OBJECT_CLASS_VIOLATION;
1592                case 66 : return NOT_ALLOWED_ON_NON_LEAF;
1593                case 67 : return NOT_ALLOWED_ON_RDN;
1594                case 68 : return ENTRY_ALREADY_EXISTS;
1595                case 69 : return OBJECT_CLASS_MODS_PROHIBITED;
1596                case 71 : return AFFECTS_MULTIPLE_DSAS;
1597                case 80 : return OTHER;
1598                case 118: return CANCELED;
1599                case 129: return NO_SUCH_OPERATION;
1600                case 120: return TOO_LATE;
1601                case 121: return CANNOT_CANCEL;
1602                default : return UNKNOWN;
1603            }
1604        }
1605        
1606    
1607    
1608        /**
1609         * Gets the set of general error codes.
1610         * 
1611         * @return array of result codes enumerations
1612         * @see #GENERAL_CODES
1613         */
1614        public static Set<ResultCodeEnum> getGeneralCodes()
1615        {
1616            // Must clone to prevent array content alterations
1617            return GENERAL_CODES;
1618        }
1619    
1620    
1621        /**
1622         * Gets the set of result code enumerations that do not represent
1623         * operational failures.
1624         * 
1625         * @return array of result codes enumerations
1626         * @see #NON_ERRONEOUS_CODES
1627         */
1628        public static Set<ResultCodeEnum> getNonErroneousCodes()
1629        {
1630            // Must clone to prevent array content alterations
1631            return NON_ERRONEOUS_CODES;
1632        }
1633    
1634    
1635        /**
1636         * Gets an array of result code enumerations that report a problem related
1637         * to an attribute specified by the client in their request message..
1638         * 
1639         * @return array of result codes enumerations
1640         * @see #ATTRIBUTE_CODES
1641         */
1642        public static Set<ResultCodeEnum> getAttributeCodes()
1643        {
1644            // Must clone to prevent array content alterations
1645            return ATTRIBUTE_CODES;
1646        }
1647    
1648    
1649        /**
1650         * Gets an array of result code enumerations that report a problem related
1651         * to a distinguished name provided as an argument to a request message.
1652         * 
1653         * @return array of result codes enumerations
1654         * @see #NAME_CODES
1655         */
1656        public static Set<ResultCodeEnum> getNameCodes()
1657        {
1658            // Must clone to prevent array content alterations
1659            return NAME_CODES;
1660        }
1661    
1662    
1663        /**
1664         * Gets an array of result code enumerations that report a problem related
1665         * to a problem in carrying out an operation for security reasons.
1666         * 
1667         * @return array of result codes enumerations
1668         * @see #SECURITY_CODES
1669         */
1670        public static Set<ResultCodeEnum> getSecurityCodes()
1671        {
1672            // Must clone to prevent array content alterations
1673            return SECURITY_CODES;
1674        }
1675    
1676    
1677        /**
1678         * Gets an array of result code enumerations that report a problem related
1679         * to the provision of the service.
1680         * 
1681         * @return array of result codes enumerations
1682         * @see #SERVICE_CODES
1683         */
1684        public static Set<ResultCodeEnum> getServiceCodes()
1685        {
1686            // Must clone to prevent array content alterations
1687            return SERVICE_CODES;
1688        }
1689    
1690    
1691        /**
1692         * Gets an array of result code enumerations that reports problems related
1693         * to attempts to add, delete, or modify information in the DIB.
1694         * 
1695         * @return array of result codes enumerations
1696         * @see #UPDATE_CODES
1697         */
1698        public static Set<ResultCodeEnum> getUpdateCodes()
1699        {
1700            // Must clone to prevent array content alterations
1701            return UPDATE_CODES;
1702        }
1703    
1704    
1705        /**
1706         * Gets an array of result code enumerations common to all operations.
1707         * 
1708         * @return an array of common operation ResultCodeEnum's
1709         * @see #COMMON_CODES
1710         */
1711        public static Set<ResultCodeEnum> getCommonCodes()
1712        {
1713            return COMMON_CODES;
1714        }
1715    
1716    
1717        /**
1718         * Gets an array of result code enumerations resulting from bind operations.
1719         * 
1720         * @return an array of bind operation ResultCodeEnum's
1721         * @see #BIND_CODES
1722         */
1723        public static Set<ResultCodeEnum> getBindCodes()
1724        {
1725            return BIND_CODES;
1726        }
1727    
1728    
1729        /**
1730         * Gets an array of result code enumerations resulting from search
1731         * operations.
1732         * 
1733         * @return an array of search operation ResultCodeEnum's
1734         * @see #SEARCH_CODES
1735         */
1736        public static Set<ResultCodeEnum> getSearchCodes()
1737        {
1738            return SEARCH_CODES;
1739        }
1740    
1741    
1742        /**
1743         * Gets an array of result code enumerations resulting from modify
1744         * operations.
1745         * 
1746         * @return an array of modify operation ResultCodeEnum's
1747         * @see #MODIFY_CODES
1748         */
1749        public static Set<ResultCodeEnum> getModifyCodes()
1750        {
1751            return MODIFY_CODES;
1752        }
1753    
1754    
1755        /**
1756         * Gets an array of result code enumerations resulting from add operations.
1757         * 
1758         * @return an array of add operation ResultCodeEnum's
1759         * @see #ADD_CODES
1760         */
1761        public static Set<ResultCodeEnum> getAddCodes()
1762        {
1763            return ADD_CODES;
1764        }
1765    
1766    
1767        /**
1768         * Gets an array of result code enumerations resulting from delete
1769         * operations.
1770         * 
1771         * @return an array of delete operation ResultCodeEnum's
1772         * @see #DELETE_CODES
1773         */
1774        public static Set<ResultCodeEnum> getDeleteCodes()
1775        {
1776            return DELETE_CODES;
1777        }
1778    
1779    
1780        /**
1781         * Gets an array of result code enumerations resulting from modifyDn
1782         * operations.
1783         * 
1784         * @return an array of modifyDn operation ResultCodeEnum's
1785         * @see #MODIFYDN_CODES
1786         */
1787        public static Set<ResultCodeEnum> getModifyDnCodes()
1788        {
1789            return MODIFYDN_CODES;
1790        }
1791    
1792    
1793        /**
1794         * Gets an array of result code enumerations resulting from compare
1795         * operations.
1796         * 
1797         * @return an array of compare operation ResultCodeEnum's
1798         * @see #COMPARE_CODES
1799         */
1800        public static Set<ResultCodeEnum> getCompareCodes()
1801        {
1802            return COMPARE_CODES;
1803        }
1804    
1805    
1806        /**
1807         * Gets an array of result code enumerations resulting from extended
1808         * operations.
1809         * 
1810         * @return an array of extended operation ResultCodeEnum's
1811         * @see #EXTENDED_CODES
1812         */
1813        public static Set<ResultCodeEnum> getExtendedCodes()
1814        {
1815            return EXTENDED_CODES;
1816        }
1817    
1818    
1819        /**
1820         * Gets all of the result code enumerations defined.
1821         * 
1822         * @return an array of all defined result codes
1823         * @see #ALL_CODES
1824         */
1825        public static Set<ResultCodeEnum> getAllCodes()
1826        {
1827            // Must clone to prevent array content tampering.
1828            return ALL_CODES;
1829        }
1830    
1831    
1832        // ------------------------------------------------------------------------
1833        // Getting Result Code Enumeration Object Using Integer Values
1834        // ------------------------------------------------------------------------
1835        // ------------------------------------------------------------------------
1836        // JNDI Exception to ResultCodeEnum Mappings
1837        // ------------------------------------------------------------------------
1838    
1839        /**
1840         * A set of ResultCodes containing those that may correspond to a
1841         * {@link NamingException}.
1842         * <ul>
1843         * <li><a href="#OPERATIONSERROR">operationsError(1)</a></li>
1844         * <li><a href="#ALIAS_PROBLEM">aliasProblem(33)</a></li>
1845         * <li><a href="#ALIAS_DEREFERENCING_PROBLEM">aliasDereferencingProblem(36)</a></li>
1846         * <li><a href="#LOOP_DETECT">loopDetect(54)</a></li>
1847         * <li><a href="#AFFECTS_MULTIPLE_DSAS">affectsMultipleDSAs(71)</a></li>
1848         * <li><a href="#OTHER">other(80)</a></li>
1849         * </ul>
1850         */
1851        public static final Set<ResultCodeEnum> NAMINGEXCEPTION_CODES;
1852        static
1853        {
1854            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1855            set.add( ResultCodeEnum.OPERATIONS_ERROR );
1856            set.add( ResultCodeEnum.ALIAS_PROBLEM );
1857            set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
1858            set.add( ResultCodeEnum.LOOP_DETECT );
1859            set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
1860            set.add( ResultCodeEnum.OTHER );
1861            NAMINGEXCEPTION_CODES = Collections.unmodifiableSet( set );
1862        }
1863    
1864        /**
1865         * A set of ResultCodes containing those that may correspond to a
1866         * {@link Exception}.
1867         * <ul>
1868         * <li><a href="#AUTH_METHOD_NOT_SUPPORTED">authMethodNotSupported(7)</a></li>
1869         * <li><a href="#STRONG_AUTH_REQUIRED">strongAuthRequired(8)</a></li>
1870         * <li><a href="#CONFIDENTIALITY_REQUIRED">confidentialityRequired(13)</a></li>
1871         * <li><a
1872         * href="#INAPPROPRIATE_AUTHENTICATION">inappropriateAuthentication(48)</a></li>
1873         * </ul>
1874         */
1875        public static final Set<ResultCodeEnum> AUTHENTICATIONNOTSUPPOERTEDEXCEPTION_CODES;
1876        static
1877        {
1878            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1879            set.add( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
1880            set.add( ResultCodeEnum.STRONG_AUTH_REQUIRED );
1881            set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
1882            set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
1883            AUTHENTICATIONNOTSUPPOERTEDEXCEPTION_CODES = Collections.unmodifiableSet( set );
1884        }
1885    
1886        /**
1887         * A set of ResultCodes containing those that may correspond to a
1888         * {@link Exception}.
1889         * <ul>
1890         * <li><a href="#BUSY">busy(51)</a></li>
1891         * <li><a href="#UNAVAILABLE">unavailable(52)</a></li>
1892         * </ul>
1893         */
1894        public static final Set<ResultCodeEnum> SERVICEUNAVAILABLE_CODES;
1895        static
1896        {
1897            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1898            set.add( ResultCodeEnum.BUSY );
1899            set.add( ResultCodeEnum.UNAVAILABLE );
1900            SERVICEUNAVAILABLE_CODES = Collections.unmodifiableSet( set );
1901        }
1902    
1903        /**
1904         * A set of ResultCodes containing those that may correspond to a
1905         * {@link Exception}.
1906         * <ul>
1907         * <li><a href="#CONSTRAINT_VIOLATION">constraintViolation(19)</a></li>
1908         * <li><a href="#INVALID_ATTRIBUTE_SYNTAX">invalidAttributeSyntax(21)</a></li>
1909         * </ul>
1910         */
1911        public static final Set<ResultCodeEnum> INVALIDATTRIBUTEVALUEEXCEPTION_CODES;
1912        static
1913        {
1914            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1915            set.add( ResultCodeEnum.CONSTRAINT_VIOLATION );
1916            set.add( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
1917            INVALIDATTRIBUTEVALUEEXCEPTION_CODES = Collections.unmodifiableSet( set );
1918        }
1919    
1920        /**
1921         * A set of ResultCodes containing those that may correspond to a
1922         * {@link Exception}.
1923         * <ul>
1924         * <li><a href="#PARTIAL_RESULTS">partialResults(9)</a></li>
1925         * <li><a href="#REFERRAL">referral(10)</a></li>
1926         * </ul>
1927         */
1928        public static final Set<ResultCodeEnum> PARTIAL_RESULTSEXCEPTION_CODES;
1929        static
1930        {
1931            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1932            set.add( ResultCodeEnum.PARTIAL_RESULTS );
1933            set.add( ResultCodeEnum.REFERRAL );
1934            PARTIAL_RESULTSEXCEPTION_CODES = Collections.unmodifiableSet( set );
1935        }
1936    
1937        /**
1938         * A set of ResultCodes containing those that may correspond to a
1939         * {@link Exception}.
1940         * <ul>
1941         * <li><a href="#REFERRAL">referal(9)</a></li>
1942         * <li><a href="#ADMIN_LIMIT_EXCEEDED">adminLimitExceeded(11)</a></li>
1943         * </ul>
1944         */
1945        public static final Set<ResultCodeEnum> LIMITEXCEEDEDEXCEPTION_CODES;
1946        static
1947        {
1948            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1949            set.add( ResultCodeEnum.REFERRAL );
1950            set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
1951            LIMITEXCEEDEDEXCEPTION_CODES = Collections.unmodifiableSet( set );
1952        }
1953    
1954        /**
1955         * A set of ResultCodes containing those that may correspond to a
1956         * {@link Exception}.
1957         * <ul>
1958         * <li><a
1959         * href="#UNAVAILABLECRITICALEXTENTION">unavailableCriticalExtention(12)</a></li>
1960         * <li><a href="#UNWILLING_TO_PERFORM">unwillingToPerform(53)</a></li>
1961         * </ul>
1962         */
1963        public static final Set<ResultCodeEnum> OPERATIONNOTSUPPOERTEXCEPTION_CODES;
1964        static
1965        {
1966            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1967            set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
1968            set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
1969            OPERATIONNOTSUPPOERTEXCEPTION_CODES = Collections.unmodifiableSet( set );
1970        }
1971    
1972        /**
1973         * A set of ResultCodes containing those that may correspond to a
1974         * {@link Exception}.
1975         * <ul>
1976         * <li><a href="#INVALID_DN_SYNTAX">invalidDNSyntax(34)</a></li>
1977         * <li><a href="#NAMING_VIOLATION">namingViolation(64)</a></li>
1978         * </ul>
1979         */
1980        public static final Set<ResultCodeEnum> INVALIDNAMEEXCEPTION_CODES;
1981        static
1982        {
1983            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
1984            set.add( ResultCodeEnum.INVALID_DN_SYNTAX );
1985            set.add( ResultCodeEnum.NAMING_VIOLATION );
1986            INVALIDNAMEEXCEPTION_CODES = Collections.unmodifiableSet( set );
1987        }
1988    
1989        /**
1990         * A set of ResultCodes containing those that may correspond to a
1991         * {@link javax.naming.directory.SchemaViolationException}.
1992         * <ul>
1993         * <li><a href="#OBJECT_CLASS_VIOLATION">objectClassViolation(65)</a></li>
1994         * <li><a href="#NOT_ALLOWED_ON_RDN">notAllowedOnRDN(67)</a></li>
1995         * <li><a href="#OBJECT_CLASS_MODS_PROHIBITED">objectClassModsProhibited(69)</a></li>
1996         * </ul>
1997         */
1998        public static final Set<ResultCodeEnum> SCHEMAVIOLATIONEXCEPTION_CODES;
1999        static
2000        {
2001            Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
2002            set.add( ResultCodeEnum.OBJECT_CLASS_VIOLATION );
2003            set.add( ResultCodeEnum.NOT_ALLOWED_ON_RDN );
2004            set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
2005            SCHEMAVIOLATIONEXCEPTION_CODES = Collections.unmodifiableSet( set );
2006        }
2007    
2008    
2009        /**
2010         * Takes a guess at the result code to use if it cannot figure it out from
2011         * known Throwable to result code mappings. Some however are ambiguous
2012         * mapping the same Throwable to multiple codes. If no code can be resolved
2013         * then {@link ResultCodeEnum#OTHER} is returned.
2014         * 
2015         * @param t
2016         *            the throwable to estimate a result code for
2017         * @param type
2018         *            the type of operation being performed
2019         * @return the result code or a good estimate of one
2020         */
2021        public static ResultCodeEnum getBestEstimate( Throwable t, MessageTypeEnum type )
2022        {
2023            Set<ResultCodeEnum> set = getResultCodes( t );
2024    
2025            if ( set.isEmpty() )
2026            {
2027                return ResultCodeEnum.OTHER;
2028            }
2029    
2030            if ( set.size() == 1 )
2031            {
2032                return set.iterator().next();
2033            }
2034    
2035            if ( type == null )
2036            {
2037                Set<ResultCodeEnum> tmp = new HashSet<ResultCodeEnum>();
2038                tmp.addAll( set );
2039                tmp.removeAll( NON_ERRONEOUS_CODES );
2040    
2041                if ( tmp.isEmpty() )
2042                {
2043                    return ResultCodeEnum.OTHER;
2044                }
2045    
2046                return tmp.iterator().next();
2047            }
2048    
2049            Set<ResultCodeEnum> candidates = EMPTY_RESULT_CODE_SET;
2050            
2051            switch ( type )
2052            {
2053                case ABANDON_REQUEST :
2054                    return set.iterator().next();
2055                    
2056                case ADD_REQUEST :
2057                    candidates = intersection( set, ADD_CODES );
2058                    break;
2059                    
2060                case ADD_RESPONSE :
2061                    candidates = intersection( set, ADD_CODES );
2062                    break;
2063                    
2064                case BIND_REQUEST :
2065                    candidates = intersection( set, BIND_CODES );
2066                    break;
2067                    
2068                case BIND_RESPONSE :
2069                    candidates = intersection( set, BIND_CODES );
2070                    break;
2071                    
2072                case COMPARE_REQUEST :
2073                    candidates = intersection( set, COMPARE_CODES );
2074                    break;
2075                    
2076                case COMPARE_RESPONSE :
2077                    candidates = intersection( set, COMPARE_CODES );
2078                    break;
2079                    
2080                case DEL_REQUEST :
2081                    candidates = intersection( set, DELETE_CODES );
2082                    break;
2083                    
2084                case DEL_RESPONSE :
2085                    candidates = intersection( set, DELETE_CODES );
2086                    break;
2087                    
2088                case EXTENDED_REQ :
2089                    candidates = intersection( set, EXTENDED_CODES );
2090                    break;
2091                    
2092                case EXTENDED_RESP :
2093                    candidates = intersection( set, EXTENDED_CODES );
2094                    break;
2095                    
2096                case MOD_DN_REQUEST :
2097                    candidates = intersection( set, MODIFYDN_CODES );
2098                    break;
2099                    
2100                case MOD_DN_RESPONSE :
2101                    candidates = intersection( set, MODIFYDN_CODES );
2102                    break;
2103                    
2104                case MODIFY_REQUEST :
2105                    candidates = intersection( set, MODIFY_CODES );
2106                    break;
2107                    
2108                case MODIFY_RESPONSE :
2109                    candidates = intersection( set, MODIFY_CODES );
2110                    break;
2111                    
2112                case SEARCH_REQUEST :
2113                    candidates = intersection( set, SEARCH_CODES );
2114                    break;
2115                    
2116                case SEARCH_RES_DONE :
2117                    candidates = intersection( set, SEARCH_CODES );
2118                    break;
2119                    
2120                case SEARCH_RES_ENTRY :
2121                    candidates = intersection( set, SEARCH_CODES );
2122                    break;
2123                    
2124                case SEARCH_RES_REF :
2125                    candidates = intersection( set, SEARCH_CODES );
2126                    break;
2127                    
2128                case UNBIND_REQUEST :
2129                    return set.iterator().next();
2130            }
2131    
2132            // we don't want any codes that do not have anything to do w/ errors
2133            candidates.removeAll( NON_ERRONEOUS_CODES );
2134    
2135            if ( candidates.isEmpty() )
2136            {
2137                return ResultCodeEnum.OTHER;
2138            }
2139    
2140            return candidates.iterator().next();
2141        }
2142    
2143    
2144        private static Set<ResultCodeEnum> intersection( Set<ResultCodeEnum> s1, Set<ResultCodeEnum> s2 )
2145        {
2146            if ( s1.isEmpty() || s2.isEmpty() )
2147            {
2148                return new HashSet<ResultCodeEnum>();
2149            }
2150    
2151            Set<ResultCodeEnum> intersection = new HashSet<ResultCodeEnum>();
2152            
2153            if ( s1.size() <= s2.size() )
2154            {
2155                for ( ResultCodeEnum item:s1 )
2156                {
2157                    if ( s2.contains( item ) )
2158                    {
2159                        intersection.add( item );
2160                    }
2161                }
2162            }
2163            else
2164            {
2165                for ( ResultCodeEnum item:s2 )
2166                {
2167                    if ( s1.contains( item ) )
2168                    {
2169                        intersection.add( item );
2170                    }
2171                }
2172            }
2173    
2174            return intersection;
2175        }
2176    
2177    
2178        /**
2179         * Gets the set of result codes a Throwable may map to. If the throwable
2180         * does not map to any result code at all an empty set is returned. The
2181         * following Throwables and their subclasses map to result codes:
2182         * 
2183         * <pre>
2184         * 
2185         *  Unambiguous Exceptions
2186         *  ======================
2187         * 
2188         *  CommunicationException              ==&gt; operationsError(1)
2189         *  TimeLimitExceededException          ==&gt; timeLimitExceeded(3)
2190         *  SizeLimitExceededException          ==&gt; sizeLimitExceeded(4)
2191         *  AuthenticationException             ==&gt; invalidCredentials(49)
2192         *  NoPermissionException               ==&gt; insufficientAccessRights(50)
2193         *  NoSuchAttributeException            ==&gt; noSuchAttribute(16)
2194         *  InvalidAttributeIdentifierException ==&gt; undefinedAttributeType(17)
2195         *  InvalidSearchFilterException        ==&gt; inappropriateMatching(18)
2196         *  AttributeInUseException             ==&gt; attributeOrValueExists(20)
2197         *  NameNotFoundException               ==&gt; NO_SUCH_OBJECT(32)
2198         *  NameAlreadyBoundException           ==&gt; entryAlreadyExists(68)
2199         *  ContextNotEmptyException            ==&gt; notAllowedOnNonLeaf(66)
2200         * 
2201         * 
2202         *  Ambiguous Exceptions
2203         *  ====================
2204         * 
2205         *  NamingException
2206         *  ---------------
2207         *  operationsError(1)
2208         *  aliasProblem(33)
2209         *  aliasDereferencingProblem(36)
2210         *  loopDetect(54)
2211         *  affectsMultipleDSAs(71)
2212         *  other(80)
2213         * 
2214         *  AuthenticationNotSupportedException
2215         *  -----------------------------------
2216         *  authMethodNotSupported (7)
2217         *  strongAuthRequired (8)
2218         *  confidentialityRequired (13)
2219         *  inappropriateAuthentication(48)
2220         * 
2221         *  ServiceUnavailableException
2222         *  ---------------------------
2223         *  busy(51)
2224         *  unavailable(52)
2225         * 
2226         *  InvalidAttributeValueException
2227         *  ------------------------------
2228         *  constraintViolation(19)
2229         *  invalidAttributeSyntax(21)
2230         * 
2231         *  PartialResultException
2232         *  ----------------------
2233         *  partialResults(9)
2234         *  referral(10)
2235         * 
2236         *  LimitExceededException
2237         *  ----------------------
2238         *  referal(9)
2239         *  adminLimitExceeded(11)
2240         * 
2241         *  OperationNotSupportedException
2242         *  ------------------------------
2243         *  unavailableCriticalExtention(12)
2244         *  unwillingToPerform(53)
2245         * 
2246         *  InvalidNameException
2247         *  --------------------
2248         *  invalidDNSyntax(34)
2249         *  namingViolation(64)
2250         * 
2251         *  SchemaViolationException
2252         *  ------------------------
2253         *  objectClassViolation(65)
2254         *  notAllowedOnRDN(67)
2255         *  objectClassModsProhibited(69)
2256         * 
2257         * </pre>
2258         * 
2259         * @param t
2260         *            the Throwable to find the result code mappings for
2261         * @return the set of mapped result codes
2262         */
2263        public static Set<ResultCodeEnum> getResultCodes( Throwable t )
2264        {
2265            ResultCodeEnum rc;
2266            
2267            if ( ( rc = getResultCode( t ) ) != null )
2268            {
2269                return Collections.singleton( rc );
2270            }
2271    
2272            if ( t instanceof SchemaViolationException )
2273            {
2274                return SCHEMAVIOLATIONEXCEPTION_CODES;
2275            }
2276    
2277            if ( t instanceof InvalidNameException )
2278            {
2279                return INVALIDNAMEEXCEPTION_CODES;
2280            }
2281    
2282            if ( t instanceof OperationNotSupportedException )
2283            {
2284                return OPERATIONNOTSUPPOERTEXCEPTION_CODES;
2285            }
2286    
2287            if ( t instanceof LimitExceededException )
2288            {
2289                return LIMITEXCEEDEDEXCEPTION_CODES;
2290            }
2291    
2292            if ( t instanceof PartialResultException )
2293            {
2294                return PARTIAL_RESULTSEXCEPTION_CODES;
2295            }
2296    
2297            if ( t instanceof InvalidAttributeValueException )
2298            {
2299                return INVALIDATTRIBUTEVALUEEXCEPTION_CODES;
2300            }
2301    
2302            if ( t instanceof ServiceUnavailableException )
2303            {
2304                return SERVICEUNAVAILABLE_CODES;
2305            }
2306    
2307            if ( t instanceof AuthenticationNotSupportedException )
2308            {
2309                return AUTHENTICATIONNOTSUPPOERTEDEXCEPTION_CODES;
2310            }
2311    
2312            // keep this last because others are subtypes and thier evaluation
2313            // may be shorted otherwise by this comparison here
2314            if ( t instanceof NamingException )
2315            {
2316                return NAMINGEXCEPTION_CODES;
2317            }
2318    
2319            return EMPTY_RESULT_CODE_SET;
2320        }
2321    
2322    
2323        /**
2324         * Gets an LDAP result code from a Throwable if it can resolve it
2325         * unambiguously or returns null if it cannot resolve the exception to a
2326         * single ResultCode. If the Throwable is an instance of LdapException this
2327         * is already done for us, otherwise we use the following mapping:
2328         * 
2329         * <pre>
2330         * 
2331         *  Unambiguous Exceptions
2332         *  ======================
2333         * 
2334         *  CommunicationException              ==&gt; operationsError(1)
2335         *  TimeLimitExceededException          ==&gt; timeLimitExceeded(3)
2336         *  SizeLimitExceededException          ==&gt; sizeLimitExceeded(4)
2337         *  AuthenticationException             ==&gt; invalidCredentials(49)
2338         *  NoPermissionException               ==&gt; insufficientAccessRights(50)
2339         *  NoSuchAttributeException            ==&gt; noSuchAttribute(16)
2340         *  InvalidAttributeIdentifierException ==&gt; undefinedAttributeType(17)
2341         *  InvalidSearchFilterException        ==&gt; inappropriateMatching(18)
2342         *  AttributeInUseException             ==&gt; attributeOrValueExists(20)
2343         *  NameNotFoundException               ==&gt; NO_SUCH_OBJECT(32)
2344         *  NameAlreadyBoundException           ==&gt; entryAlreadyExists(68)
2345         *  ContextNotEmptyException            ==&gt; notAllowedOnNonLeaf(66)
2346         * </pre>
2347         * 
2348         * If we cannot find a mapping then null is returned.
2349         * 
2350         * @param t The exception for which we need a ResultCodeEnum
2351         * @return The ResultCodeEnum associated wit the given exception 
2352         */
2353        public static ResultCodeEnum getResultCode( Throwable t )
2354        {
2355            if ( t instanceof LdapException )
2356            {
2357                return ( ( LdapException ) t ).getResultCode();
2358            }
2359    
2360            if ( t instanceof CommunicationException )
2361            {
2362                return ResultCodeEnum.PROTOCOL_ERROR;
2363            }
2364    
2365            if ( t instanceof TimeLimitExceededException )
2366            {
2367                return ResultCodeEnum.TIME_LIMIT_EXCEEDED;
2368            }
2369    
2370            if ( t instanceof SizeLimitExceededException )
2371            {
2372                return ResultCodeEnum.SIZE_LIMIT_EXCEEDED;
2373            }
2374    
2375            if ( t instanceof AuthenticationException )
2376            {
2377                return ResultCodeEnum.INVALID_CREDENTIALS;
2378            }
2379    
2380            if ( t instanceof NoPermissionException )
2381            {
2382                return ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS;
2383            }
2384    
2385            if ( t instanceof NoSuchAttributeException )
2386            {
2387                return ResultCodeEnum.NO_SUCH_ATTRIBUTE;
2388            }
2389    
2390            if ( t instanceof InvalidAttributeIdentifierException )
2391            {
2392                return ResultCodeEnum.UNDEFINED_ATTRIBUTE_TYPE;
2393            }
2394    
2395            if ( t instanceof InvalidSearchFilterException )
2396            {
2397                return ResultCodeEnum.INAPPROPRIATE_MATCHING;
2398            }
2399    
2400            if ( t instanceof AttributeInUseException )
2401            {
2402                return ResultCodeEnum.ATTRIBUTE_OR_VALUE_EXISTS;
2403            }
2404    
2405            if ( t instanceof NameNotFoundException )
2406            {
2407                return ResultCodeEnum.NO_SUCH_OBJECT;
2408            }
2409    
2410            if ( t instanceof NameAlreadyBoundException )
2411            {
2412                return ResultCodeEnum.ENTRY_ALREADY_EXISTS;
2413            }
2414    
2415            if ( t instanceof ContextNotEmptyException )
2416            {
2417                return ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF;
2418            }
2419    
2420            return null;
2421        }
2422    }