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 */
020package org.apache.directory.ldap.client.api;
021
022
023import java.io.IOException;
024import java.util.List;
025
026import org.apache.directory.shared.asn1.util.Oid;
027import org.apache.directory.shared.ldap.codec.api.LdapApiService;
028import org.apache.directory.shared.ldap.model.cursor.EntryCursor;
029import org.apache.directory.shared.ldap.model.cursor.SearchCursor;
030import org.apache.directory.shared.ldap.model.entry.Entry;
031import org.apache.directory.shared.ldap.model.entry.Modification;
032import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
033import org.apache.directory.shared.ldap.model.entry.Value;
034import org.apache.directory.shared.ldap.model.exception.LdapException;
035import org.apache.directory.shared.ldap.model.message.AbandonRequest;
036import org.apache.directory.shared.ldap.model.message.AddRequest;
037import org.apache.directory.shared.ldap.model.message.AddResponse;
038import org.apache.directory.shared.ldap.model.message.BindRequest;
039import org.apache.directory.shared.ldap.model.message.BindResponse;
040import org.apache.directory.shared.ldap.model.message.CompareRequest;
041import org.apache.directory.shared.ldap.model.message.CompareResponse;
042import org.apache.directory.shared.ldap.model.message.Control;
043import org.apache.directory.shared.ldap.model.message.DeleteRequest;
044import org.apache.directory.shared.ldap.model.message.DeleteResponse;
045import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
046import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
047import org.apache.directory.shared.ldap.model.message.ModifyDnRequest;
048import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
049import org.apache.directory.shared.ldap.model.message.ModifyRequest;
050import org.apache.directory.shared.ldap.model.message.ModifyResponse;
051import org.apache.directory.shared.ldap.model.message.SearchRequest;
052import org.apache.directory.shared.ldap.model.message.SearchScope;
053import org.apache.directory.shared.ldap.model.name.Dn;
054import org.apache.directory.shared.ldap.model.name.Rdn;
055import org.apache.directory.shared.ldap.model.schema.SchemaManager;
056
057
058/**
059 * The root interface for all the LDAP connection implementations.
060 *
061 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
062 */
063public interface LdapConnection
064{
065    /**
066     * Check if we are connected
067     *
068     * @return <code>true</code> if we are connected.
069     */
070    boolean isConnected();
071
072
073    /**
074     * Check if we are authenticated
075     *
076     * @return <code>true</code> if we are connected.
077     */
078    boolean isAuthenticated();
079
080
081    /**
082     * Connect to the remote LDAP server.
083     *
084     * @return <code>true</code> if the connection is established, false otherwise
085     * @throws LdapException if some error occurred
086     * @throws IOException if an I/O exception occurred
087     */
088    boolean connect() throws LdapException, IOException;
089
090
091    /**
092     * Disconnect from the remote LDAP server
093     *
094     * @return <code>true</code> if the connection is closed, false otherwise
095     * @throws IOException if some I/O error occurs
096     */
097    boolean close() throws IOException;
098
099
100    //------------------------ The LDAP operations ------------------------//
101    // Add operations                                                      //
102    //---------------------------------------------------------------------//
103    /**
104     * Add an entry to the server. This is a blocking add : the user has
105     * to wait for the response until the AddResponse is returned.
106     *
107     * @param entry The entry to add
108     * @return the add operation's response
109     * @throws LdapException if some error occurred
110     */
111    void add( Entry entry ) throws LdapException;
112
113
114    /**
115     * Add an entry present in the AddRequest to the server.
116     *
117     * @param addRequest the request object containing an entry and controls(if any)
118     * @return the add operation's response
119     * @throws LdapException if some error occurred
120     */
121    AddResponse add( AddRequest addRequest ) throws LdapException;
122
123
124    /**
125     * Abandons a request submitted to the server for performing a particular operation
126     *
127     * The abandonRequest is always non-blocking, because no response is expected
128     *
129     * @param messageId the ID of the request message sent to the server
130     */
131    void abandon( int messageId );
132
133
134    /**
135     * An abandon request essentially with the request message ID of the operation to be canceled
136     * and/or potentially some controls and timeout (the controls and timeout are not mandatory).
137     *
138     * The abandonRequest is always non-blocking, because no response is expected
139     *
140     * @param abandonRequest the abandon operation's request
141     */
142    void abandon( AbandonRequest abandonRequest );
143
144
145    /**
146     * Bind on a server, using the LdapConnectionConfig informations
147     *
148     * @return The BindResponse LdapResponse
149     * @throws LdapException if some error occurred
150     * @throws IOException if an I/O exception occurred
151     */
152    void bind() throws LdapException, IOException;
153
154
155    /**
156     * Anonymous Bind on a server.
157     *
158     * @return The BindResponse LdapResponse
159     * @throws LdapException if some error occurred
160     * @throws IOException if an I/O exception occurred
161     */
162    void anonymousBind() throws LdapException, IOException;
163
164
165    /**
166     * Unauthenticated authentication bind
167     *
168     * @param name The name we use to authenticate the user. It must be a
169     * valid Dn
170     * @return The BindResponse LdapResponse
171     * @throws LdapException if some error occurred
172     * @throws IOException if an I/O exception occurred
173     */
174    void bind( String name ) throws LdapException, IOException;
175
176
177    /**
178     * Simple Bind on a server.
179     *
180     * @param name The name we use to authenticate the user. It must be a
181     * valid Dn
182     * @param credentials The password. It can't be null
183     * @return The BindResponse LdapResponse
184     * @throws LdapException if some error occurred
185     * @throws IOException if an I/O exception occurred
186     */
187    void bind( String name, String credentials ) throws LdapException, IOException;
188
189
190    /**
191     * Unauthenticated authentication Bind on a server.
192     *
193     * @param name The name we use to authenticate the user. It must be a
194     * valid Dn
195     * @return The BindResponse LdapResponse
196     * @throws LdapException if some error occurred
197     * @throws IOException if an I/O exception occurred
198     */
199    void bind( Dn name ) throws LdapException, IOException;
200
201
202    /**
203     * Simple Bind on a server.
204     *
205     * @param name The name we use to authenticate the user. It must be a
206     * valid Dn
207     * @param credentials The password. It can't be null
208     * @return The BindResponse LdapResponse
209     * @throws LdapException if some error occurred
210     * @throws IOException if an I/O exception occurred
211     */
212    void bind( Dn name, String credentials ) throws LdapException, IOException;
213
214
215    /**
216     * Bind to the server using a BindRequest object.
217     *
218     * @param bindRequest The BindRequest POJO containing all the needed
219     * parameters
220     * @return A LdapResponse containing the result
221     * @throws LdapException if some error occurred
222     * @throws IOException if an I/O exception occurred
223     */
224    BindResponse bind( BindRequest bindRequest ) throws LdapException, IOException;
225
226
227    /**
228     * Do a search, on the base object, using the given filter. The
229     * SearchRequest parameters default to :
230     * Scope : ONE
231     * DerefAlias : ALWAYS
232     * SizeLimit : none
233     * TimeLimit : none
234     * TypesOnly : false
235     * Attributes : all the user's attributes.
236     * This method is blocking.
237     *
238     * @param baseDn The base for the search. It must be a valid
239     * Dn, and can't be emtpy
240     * @param filter The filter to use for this search. It can't be empty
241     * @param scope The search scope : OBJECT, ONELEVEL or SUBTREE
242     * @param attributes The attributes to use for this search
243     * @return A search cursor on the result.
244     * @throws LdapException if some error occurred
245     */
246    EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
247        throws LdapException;
248
249
250    /**
251     * Do a search, on the base object, using the given filter. The
252     * SearchRequest parameters default to :
253     * Scope : ONE
254     * DerefAlias : ALWAYS
255     * SizeLimit : none
256     * TimeLimit : none
257     * TypesOnly : false
258     * Attributes : all the user's attributes.
259     * This method is blocking.
260     *
261     * @param baseDn The base for the search. It must be a valid
262     * Dn, and can't be emtpy
263     * @param filter The filter to use for this search. It can't be empty
264     * @param scope The search scope : OBJECT, ONELEVEL or SUBTREE
265     * @param attributes The attributes to use for this search
266     * @return A search cursor on the result.
267     * @throws LdapException if some error occurred
268     */
269    EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
270        throws LdapException;
271
272
273    /**
274     * Performs search in a synchronous mode.
275     *
276     * @param searchRequest The search configuration
277     * @return a search cursor on the result.
278     * @throws LdapException if some error occurred
279     */
280    SearchCursor search( SearchRequest searchRequest ) throws LdapException;
281
282
283    //------------------------ The LDAP operations ------------------------//
284    // Unbind operations                                                   //
285    //---------------------------------------------------------------------//
286    /**
287     * UnBind from a server. This is a request which expect no response.
288     * @throws LdapException if some error occurred
289     */
290    void unBind() throws LdapException;
291
292
293    /**
294     * Set the timeOut for the responses. We wont wait longer than this
295     * value.
296     *
297     * @param timeOut The timeout, in milliseconds
298     */
299    void setTimeOut( long timeOut );
300
301
302    /**
303     * Applies all the modifications to the entry specified by its Dn.
304     *
305     * @param dn The entry's Dn
306     * @param modifications The list of modifications to be applied
307     * @return the modify operation's response
308     * @throws LdapException in case of modify operation failure or timeout happens
309     */
310    void modify( Dn dn, Modification... modifications ) throws LdapException;
311
312
313    /**
314     * Applies all the modifications to the entry specified by its Dn.
315     *
316     * @param dn The entry's Dn
317     * @param modifications The list of modifications to be applied
318     * @return the modify operation's response
319     * @throws LdapException in case of modify operation failure or timeout happens
320     */
321    void modify( String dn, Modification... modifications ) throws LdapException;
322
323
324    /**
325     * Modifies all the attributes present in the entry by applying the same operation.
326     *
327     * @param entry the entry with the attributes to be modified
328     * @param modOp the operation to be applied on all the attributes of the above entry
329     * @return the modify operation's response
330     * @throws LdapException in case of modify operation failure or timeout happens
331     */
332    void modify( Entry entry, ModificationOperation modOp ) throws LdapException;
333
334
335    /**
336     * Performs an modify operation based on the modifications present in
337     * the ModifyRequest.
338     *
339     * @param modRequest the request for modify operation
340     * @return the modify operation's response
341     * @throws LdapException in case of modify operation failure or timeout happens
342     */
343    ModifyResponse modify( ModifyRequest modRequest ) throws LdapException;
344
345
346    /**
347     * Renames the given entryDn with new Rdn and deletes the old Rdn.
348     *
349     * @param entryDn the target Dn
350     * @param newRdn new Rdn for the target Dn
351     * @return modifyDn operation's response
352     * @throws LdapException if some error occurred
353     * @see #rename(String, String, boolean)
354     */
355    void rename( String entryDn, String newRdn ) throws LdapException;
356
357
358    /**
359     * Renames the given entryDn with new Rdn and deletes the old Rdn.
360     *
361     * @param entryDn the target Dn
362     * @param newRdn new Rdn for the target Dn
363     * @return modifyDn operation's response
364     * @throws LdapException if some error occurred
365     * @see #rename(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.name.Rdn, boolean)
366     */
367    void rename( Dn entryDn, Rdn newRdn ) throws LdapException;
368
369
370    /**
371     * Renames the given entryDn with new Rdn and deletes the old Rdn if
372     * deleteOldRdn is set to true.
373     *
374     * @param entryDn the target Dn
375     * @param newRdn new Rdn for the target Dn
376     * @param deleteOldRdn flag to indicate whether to delete the old Rdn
377     * @return modifyDn operation's response
378     * @throws LdapException if some error occurred
379     * @see #rename(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.name.Rdn, boolean)
380     */
381    void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException;
382
383
384    /**
385     * Renames the given entryDn with new Rdn and deletes the old Rdn if
386     * deleteOldRdn is set to true.
387     *
388     * @param entryDn the target Dn
389     * @param newRdn new Rdn for the target Dn
390     * @param deleteOldRdn flag to indicate whether to delete the old Rdn
391     * @return modifyDn operation's response
392     * @throws LdapException if some error occurred
393     */
394    void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException;
395
396
397    /**
398     * Moves the given entry Dn under the new superior Dn.
399     *
400     * @param entryDn the Dn of the target entry
401     * @param newSuperiorDn Dn of the new parent/superior
402     * @return modifyDn operation's response
403     * @throws LdapException if some error occurred
404     * @see #move(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.name.Dn)
405     */
406    void move( String entryDn, String newSuperiorDn ) throws LdapException;
407
408
409    /**
410     * Moves the given entry Dn under the new superior Dn.
411     *
412     * @param entryDn the Dn of the target entry
413     * @param newSuperiorDn Dn of the new parent/superior
414     * @return modifyDn operation's response
415     * @throws LdapException if some error occurred
416     */
417    void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException;
418
419
420    /**
421     * Moves and renames the given entryDn. The old Rdn will be deleted.
422     *
423     * @param entryDn The original entry Dn
424     * @param newDn The new Entry Dn
425     * @return modifyDn operations response
426     * @throws LdapException if some error occurred
427     * @see #moveAndRename(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.name.Dn, boolean)
428     */
429    void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException;
430
431
432    /**
433     * Moves and renames the given entryDn.The old Rdn will be deleted
434     *
435     * @param entryDn The original entry Dn
436     * @param newDn The new Entry Dn
437     * @return modifyDn operations response
438     * @throws LdapException if some error occurred
439     * @see #moveAndRename(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.name.Dn, boolean)
440     */
441    void moveAndRename( String entryDn, String newDn ) throws LdapException;
442
443
444    /**
445     * Moves and renames the given entryDn. The old Rdn will be deleted if requested.
446     *
447     * @param entryDn The original entry Dn
448     * @param newDn The new Entry Dn
449     * @param deleteOldRdn Tells if the old Rdn must be removed
450     * @return modifyDn operations response
451     * @throws LdapException if some error occurred
452     */
453    void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException;
454
455
456    /**
457     * Moves and renames the given entryDn. The old Rdn will be deleted if requested.
458     *
459     * @param entryDn The original entry Dn
460     * @param newDn The new Entry Dn
461     * @param deleteOldRdn Tells if the old Rdn must be removed
462     * @return modifyDn operation's response
463     * @throws LdapException if some error occurred
464     */
465    void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn )
466        throws LdapException;
467
468
469    /**
470     * Performs the modifyDn operation based on the given ModifyDnRequest.
471     *
472     * @param modDnRequest the request
473     * @return modifyDn operation's response
474     * @throws LdapException if some error occurred
475     */
476    ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException;
477
478
479    /**
480     * Deletes the entry with the given Dn.
481     *
482     * @param dn the target entry's Dn as a String
483     * @return the delete operation's response
484     * @throws LdapException If the Dn is not valid or if the deletion failed
485     */
486    void delete( String dn ) throws LdapException;
487
488
489    /**
490     * Deletes the entry with the given Dn.
491     *
492     * @param dn the target entry's Dn
493     * @return the delete operation's response
494     * @throws LdapException If the Dn is not valid or if the deletion failed
495     */
496    void delete( Dn dn ) throws LdapException;
497
498
499    /**
500     * Performs a delete operation based on the delete request object.
501     *
502     * @param deleteRequest the delete operation's request
503     * @return delete operation's response, null if a non-null listener value is provided
504     * @throws LdapException If the Dn is not valid or if the deletion failed
505     */
506    DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException;
507
508
509    /**
510     * Compares whether a given attribute's value matches that of the
511     * existing value of the attribute present in the entry with the given Dn.
512     *
513     * @param dn the target entry's String Dn
514     * @param attributeName the attribute's name
515     * @param value a String value with which the target entry's attribute value to be compared with
516     * @return compare operation's response
517     * @throws LdapException if some error occurred
518     */
519    boolean compare( String dn, String attributeName, String value ) throws LdapException;
520
521
522    /**
523     * Compares whether a given attribute's value matches that of the
524     * existing value of the attribute present in the entry with the given Dn.
525     *
526     * @param dn the target entry's String Dn
527     * @param attributeName the attribute's name
528     * @param value a byte[] value with which the target entry's attribute value to be compared with
529     * @return compare operation's response
530     * @throws LdapException if some error occurred
531     */
532    boolean compare( String dn, String attributeName, byte[] value ) throws LdapException;
533
534
535    /**
536     * Compares whether a given attribute's value matches that of the
537     * existing value of the attribute present in the entry with the given Dn.
538     *
539     * @param dn the target entry's String Dn
540     * @param attributeName the attribute's name
541     * @param value a Value<?> value with which the target entry's attribute value to be compared with
542     * @return compare operation's response
543     * @throws LdapException if some error occurred
544     */
545    boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException;
546
547
548    /**
549     * Compares whether a given attribute's value matches that of the
550     * existing value of the attribute present in the entry with the given Dn.
551     *
552     * @param dn the target entry's Dn
553     * @param attributeName the attribute's name
554     * @param value a String value with which the target entry's attribute value to be compared with
555     * @return compare operation's response
556     * @throws LdapException if some error occurred
557     */
558    boolean compare( Dn dn, String attributeName, String value ) throws LdapException;
559
560
561    /**
562     * Compares whether a given attribute's value matches that of the
563     * existing value of the attribute present in the entry with the given Dn.
564     *
565     * @param dn the target entry's Dn
566     * @param attributeName the attribute's name
567     * @param value a byte[] value with which the target entry's attribute value to be compared with
568     * @return compare operation's response
569     * @throws LdapException if some error occurred
570     */
571    boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException;
572
573
574    /**
575     * Compares whether a given attribute's value matches that of the
576     * existing value of the attribute present in the entry with the given Dn.
577     *
578     * @param dn the target entry's Dn
579     * @param attributeName the attribute's name
580     * @param value a Value<?> value with which the target entry's attribute value to be compared with
581     * @return compare operation's response
582     * @throws LdapException if some error occurred
583     */
584    boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException;
585
586
587    /**
588     * Compares an entry's attribute's value with that of the given value.
589     *
590     * @param compareRequest the CompareRequest which contains the target Dn, attribute name and value
591     * @return compare operation's response
592     * @throws LdapException if some error occurred
593     */
594    CompareResponse compare( CompareRequest compareRequest ) throws LdapException;
595
596
597    /**
598     * Sends a extended operation request to the server with the given OID and no value.
599     *
600     * @param oid the object identifier of the extended operation
601     * @return extended operation's response
602     * @throws LdapException if some error occurred
603     * @see #extended(org.apache.directory.shared.asn1.util.Oid, byte[])
604     */
605    ExtendedResponse extended( String oid ) throws LdapException;
606
607
608    /**
609     * Sends a extended operation request to the server with the given OID and value.
610     *
611     * @param oid the object identifier of the extended operation
612     * @param value value to be used by the extended operation, can be a null value
613     * @return extended operation's response
614     * @throws LdapException if some error occurred
615     * @see #extended(org.apache.directory.shared.asn1.util.Oid, byte[])
616     */
617    ExtendedResponse extended( String oid, byte[] value ) throws LdapException;
618
619
620    /**
621     * Sends a extended operation request to the server with the given OID and no value.
622     *
623     * @param oid the object identifier of the extended operation
624     * @return extended operation's response
625     * @throws LdapException if some error occurred
626     * @see #extended(org.apache.directory.shared.asn1.util.Oid, byte[])
627     */
628    ExtendedResponse extended( Oid oid ) throws LdapException;
629
630
631    /**
632     * Sends a extended operation request to the server with the given OID and value.
633     *
634     * @param oid the object identifier of the extended operation
635     * @param value value to be used by the extended operation, can be a null value
636     * @return extended operation's response
637     * @throws LdapException if some error occurred
638     */
639    ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException;
640
641
642    /**
643     * Performs an extended operation based on the Extended request object.
644     *
645     * @param extendedRequest the extended operation's request
646     * @return Extended operation's response
647     * @throws LdapException If the Dn is not valid or if the extended operation failed
648     */
649    ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException;
650
651
652    /**
653     * Tells if an Entry exists in the server.
654     * 
655     * @param dn The Dn for the entry we want to check the existence
656     * @return <code>true</code> if the entry exists, <code>false</code> otherwise. 
657     * Note that if the entry exists but if the user does not have the permission to
658     * read it, <code>false</code> will also be returned 
659     * @throws LdapException if some error occurred
660     */
661    boolean exists( String dn ) throws LdapException;
662
663
664    /**
665     * Tells if an Entry exists in the server.
666     * 
667     * @param dn The Dn for the entry we want to check the existence
668     * @return <code>true</code> if the entry exists, <code>false</code> otherwise. 
669     * Note that if the entry exists but if the user does not have the permission to
670     * read it, <code>false</code> will also be returned 
671     * @throws LdapException if some error occurred
672     */
673    boolean exists( Dn dn ) throws LdapException;
674
675
676    /**
677     * Searches for an entry having the given Dn.
678     *
679     * @param dn the Dn of the entry to be fetched
680     * @return the Entry with the given Dn or null if no entry exists with that Dn
681     * @throws LdapException in case of any problems while searching for the Dn or if the returned response contains a referral
682     * @see #lookup(org.apache.directory.shared.ldap.model.name.Dn, String...)
683     */
684    Entry lookup( Dn dn ) throws LdapException;
685
686
687    /**
688     * Searches for an entry having the given Dn.
689     *
690     * @param dn the Dn of the entry to be fetched
691     * @return the Entry with the given Dn or null if no entry exists with that Dn
692     * @throws LdapException in case of any problems while searching for the Dn or if the returned response contains a referral
693     * @see #lookup(String, String...)
694     */
695    Entry lookup( String dn ) throws LdapException;
696
697
698    /**
699     * Searches for an entry having the given Dn.
700     *
701     * @param dn the Dn of the entry to be fetched
702     * @param attributes the attributes to be returned along with entry
703     * @return the Entry with the given Dn or null if no entry exists with that Dn
704     * @throws LdapException in case of any problems while searching for the Dn or if the returned response contains a referral
705     */
706    Entry lookup( Dn dn, String... attributes ) throws LdapException;
707
708
709    /**
710     * Searches for an entry having the given Dn.
711     *
712     * @param dn the Dn of the entry to be fetched
713     * @param controls the controls to use
714     * @param attributes the attributes to be returned along with entry
715     * @return the Entry with the given Dn or null if no entry exists with that Dn
716     * @throws LdapException in case of any problems while searching for the Dn or if the returned response contains a referral
717     */
718    Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException;
719
720
721
722    /**
723     * Searches for an entry having the given Dn.
724     *
725     * @param dn the Dn of the entry to be fetched
726     * @param attributes the attributes to be returned along with entry
727     * @return the Entry with the given Dn or null if no entry exists with that Dn
728     * @throws LdapException in case of any problems while searching for the Dn or if the returned response contains a referral
729     * @see #lookup(org.apache.directory.shared.ldap.model.name.Dn, String...)
730     */
731    Entry lookup( String dn, String... attributes ) throws LdapException;
732
733
734    /**
735     * Searches for an entry having the given Dn.
736     *
737     * @param dn the Dn of the entry to be fetched
738     * @param controls the controls to use
739     * @param attributes the attributes to be returned along with entry
740     * @return the Entry with the given Dn or null if no entry exists with that Dn
741     * @throws LdapException in case of any problems while searching for the Dn or if the returned response contains a referral
742     * @see #lookup(org.apache.directory.shared.ldap.model.name.Dn, String...)
743     */
744    Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException;
745
746
747    /**
748     * Checks if a control with the given OID is supported.
749     *
750     * @param controlOID the OID of the control
751     * @return true if the control is supported, false otherwise
752     * @throws LdapException if some error occurred
753     */
754    boolean isControlSupported( String controlOID ) throws LdapException;
755
756
757    /**
758     * Get the Controls supported by server.
759     *
760     * @return a list of control OIDs supported by server
761     * @throws LdapException if some error occurred
762     */
763    List<String> getSupportedControls() throws LdapException;
764
765
766    /**
767     * Loads all the default schemas that are bundled with the API.<br><br>
768     * <b>Note:</b> This method enables <b>all</b> schemas prior to loading
769     * @throws LdapException in case of problems while loading the schema
770     */
771    void loadSchema() throws LdapException;
772
773
774    /**
775     * @return The SchemaManager associated with this LdapConection if any
776     */
777    SchemaManager getSchemaManager();
778
779    
780    /**
781     * Gets the LDAP CODEC service responsible for encoding and decoding 
782     * messages.
783     * 
784     * @return The LDAP CODEC service.
785     */
786    LdapApiService getCodecService();
787    
788    
789    /**
790     * Checks if there is a ResponseFuture associated with the given message ID.
791     *
792     * @param messageId ID of the request
793     * @return true if there is a non-null future exists, false otherwise
794     */
795    boolean doesFutureExistFor( int messageId );
796}