gnoga_2.1.2_5f127c56/deps/simple_components/gnat-sockets-connection_state_machine-ldap-client.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
--                                                                    --
--  package                         Copyright (c)  Dmitry A. Kazakov  --
--     GNAT.Sockets.Connection_State_Machine.      Luebeck            --
--     LDAP.Client                                 Summer, 2019       --
--  Interface                                                         --
--                                Last revision :  21:39 03 Aug 2019  --
--                                                                    --
--  This  library  is  free software; you can redistribute it and/or  --
--  modify it under the terms of the GNU General Public  License  as  --
--  published by the Free Software Foundation; either version  2  of  --
--  the License, or (at your option) any later version. This library  --
--  is distributed in the hope that it will be useful,  but  WITHOUT  --
--  ANY   WARRANTY;   without   even   the   implied   warranty   of  --
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  --
--  General  Public  License  for  more  details.  You  should  have  --
--  received  a  copy  of  the GNU General Public License along with  --
--  this library; if not, write to  the  Free  Software  Foundation,  --
--  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.    --
--                                                                    --
--  As a special exception, if other files instantiate generics from  --
--  this unit, or you link this unit with other files to produce  an  --
--  executable, this unit does not by  itself  cause  the  resulting  --
--  executable to be covered by the GNU General Public License. This  --
--  exception  does not however invalidate any other reasons why the  --
--  executable file might be covered by the GNU Public License.       --
--____________________________________________________________________--

with Ada.Task_Identification;  use Ada.Task_Identification;

package GNAT.Sockets.Connection_State_Machine.LDAP.Client is
--
-- Search_Result -- The result of a search operation
--
   type Search_Result (<>) is private;
--
-- Get_Entries_Number -- The number of found entries
--
--    Result - The search result
--
-- Returns :
--
--    The number of found entries
--
   function Get_Entries_Number (Result : Search_Result) return Natural;
--
-- Get_Entry_Attributes -- The attributes list of a found entry
--
--    Result - The search result
--    Index  - The index of the entry 1..Get_Entries_Number
--
-- Returns :
--
--    The entry attributes list
--
-- Exceptions :
--
--    Constraint_Error - Wrong index
--
   function Get_Entry_Attributes
            (  Result : Search_Result;
               Index  : Positive
            )  return Attributes_List;
--
-- Get_Entry_Name -- The name of a found entry
--
--    Result - The search result
--    Index  - The index of the entry 1..Get_Entries_Number
--
-- Returns :
--
--    The entry's distinguished name
--
-- Exceptions :
--
--    Constraint_Error - Wrong index
--
   function Get_Entry_Name
            (  Result : Search_Result;
               Index  : Positive
            )  return Distinguished_Name;
--
-- Get_References -- The reference URI in the search result
--
--    Result - The search result
--
-- Returns :
--
--    The list of URIs
--
   function Get_References (Result : Search_Result) return Values_List;
------------------------------------------------------------------------
--
-- LDAP_Client -- LDAP client
--
--    Listener           - The connection object
--    Message_Length     - The maximum output LDAP message length
--    Incoming_Data_Size - The arena pool size  to allocate incoming
--                         dynamic LDAP objects and string bodies
--    Outgoing_Data_Size - The arena pool size for outgoing LDAP objects
--    Input_Size         - The input buffer size
--    Output_Size        - The output buffer size
--
-- Message_Length must be larger than the encoded length of any outgoing
-- LDAP message.  Outgoing_Data_Size  determines  the size  of the arena
-- pool where are variable-length  values allocated.  This includes LDAP
-- objects  defined recursively or as variable-sized sets and sequences.
-- The arena must accommodate  data for any outgoing LDAP  message built
-- there before getting encoded. Incoming_Data_Size  determines the size
-- of the arena pool for the incoming LDAP message.
--
   type LDAP_Client is new LDAP_Peer with private;
--
-- Cancel -- Waiting for connection
--
--    Client - The LDAP client
--
-- This  procedure  is used to cancel Connect  or Wait  pending in other
-- tasks. It does not influence the communication itself. The operations
-- will propagate Cancel_Error if not yet completed.
--
   procedure Cancel (Client : in out LDAP_Client);
--
-- Connect -- Connect to a server
--
--    Client         - The LDAP client
--    Host           - The host name or IP address
--    Port           - The port number
--    Max_Connect_No - Maximal number of connection attempts
--    Timeout        - For the operation
--
-- This procedure  is used  to connect to a remote server.  When already
-- connected  the current connection  is dropped  and another initiated.
-- The procedure ends when the host is connected.
--
-- Exceptions :
--
--    Cancel_Error  - Waiting canceled by a call to Cancel
--    Socket_Error  - Socket error
--    Status_Error  - Connection failure, e.g. attempts exhausted
--    Timeout_Error - Timeout expired
--
   procedure Connect
             (  Client         : in out LDAP_Client;
                Host           : String;
                Port           : Port_Type := 389;
                Max_Connect_No : Positive  := Positive'Last;
                Timeout        : Duration  := Duration'Last
             );
--
-- Exists -- Send search request
--
--    Client  - The LDAP client
--    Name    - To check
--    Timeout - The timeout
--
-- This function is a wrapper around Send_Search used to check if a name
-- exists.
--
-- Returns :
--
--    True of Name exists
--
   function Exists
            (  Client  : LDAP_Client;
               Name    : Distinguished_Name;
               Timeout : Duration
            )  return Boolean;
--
-- Receive_Add_Response -- Received add response callback
--
--    Client   - The LDAP client
--    ID       - The message ID
--    Result   - The result code
--    Matched  - The matched name
--    Message  - The diagnostic message
--    Referral - The referral list
--
-- The default implementation does nothing.
--
   procedure Receive_Add_Response
             (  Client   : in out LDAP_Client;
                ID       : Integer_32;
                Result   : Result_Code;
                Matched  : Distinguished_Name;
                Message  : String;
                Referral : Values_List
             );
--
-- Receive_Bind_Response -- Received bind response callback
--
--    Client      - The LDAP client
--    ID          - The message ID
--    Result      - The result code
--    Matched     - The matched name
--    Message     - The diagnostic message
--    Referral    - The referral list
--    Credentials - The credentials
--
-- The default implementation does nothing.
--
   procedure Receive_Bind_Response
             (  Client      : in out LDAP_Client;
                ID          : Integer_32;
                Result      : Result_Code;
                Matched     : Distinguished_Name;
                Message     : String;
                Referral    : Values_List;
                Credentials : String
             );
--
-- Receive_Challenge -- Received bind challenge callback
--
--    Client      - The LDAP client
--    Mechanism   - The authentication mechanism
--    Matched     - The matched name
--    Message     - The diagnostic message
--    Credentials - The challenge
--
-- This procedure  is called  when  synchronous  bind request receives a
-- challenge  from  the server  when  SASL  authentication is used.  The
-- default implementation propagates Use_Error.
--
   function Receive_Challenge
            (  Client      : access LDAP_Client;
               Mechanism   : String;
               Matched     : Distinguished_Name;
               Message     : String;
               Credentials : String
            )  return String;
--
-- Receive_Compare_Response -- Received compare response callback
--
--    Client   - The LDAP client
--    ID       - The message ID
--    Result   - The result code
--    Matched  - The matched name
--    Message  - The diagnostic message
--    Referral - The referral list
--
-- The default implementation does nothing.
--
   procedure Receive_Compare_Response
             (  Client   : in out LDAP_Client;
                ID       : Integer_32;
                Result   : Result_Code;
                Matched  : Distinguished_Name;
                Message  : String;
                Referral : Values_List
             );
--
-- Receive_Delete_Response -- Received delete response callback
--
--    Client   - The LDAP client
--    ID       - The message ID
--    Result   - The result code
--    Matched  - The matched name
--    Message  - The diagnostic message
--    Referral - The referral list
--
-- The default implementation does nothing.
--
   procedure Receive_Delete_Response
             (  Client   : in out LDAP_Client;
                ID       : Integer_32;
                Result   : Result_Code;
                Matched  : Distinguished_Name;
                Message  : String;
                Referral : Values_List
             );
--
-- Receive_Extended_Response -- Received extended response callback
--
--    Client - The LDAP client
--    ID     - The message ID
--    Name   - The object identifier
--    Value  - The value
--
-- The default implementation does nothing.
--
   procedure Receive_Extended_Response
             (  Client : in out LDAP_Client;
                ID     : Integer_32;
                Name   : Object_Identifier;
                Value  : String
             );
--
-- Receive_Intermediate_Response -- Received intermediate response
--                                  callback
--    Client - The LDAP client
--    ID     - The message ID
--    Name   - The object identifier
--    Value  - The value
--
-- The default implementation does nothing.
--
   procedure Receive_Intermediate_Response
             (  Client : in out LDAP_Client;
                ID     : Integer_32;
                Name   : Object_Identifier;
                Value  : String
             );
--
-- Receive_Modify_Response -- Received modify response callback
--
--    Client   - The LDAP client
--    ID       - The message ID
--    Result   - The result code
--    Matched  - The matched name
--    Message  - The diagnostic message
--    Referral - The referral list
--
-- The default implementation does nothing.
--
   procedure Receive_Modify_Response
             (  Client   : in out LDAP_Client;
                ID       : Integer_32;
                Result   : Result_Code;
                Matched  : Distinguished_Name;
                Message  : String;
                Referral : Values_List
             );
--
-- Receive_Modify_DN_Response -- Received modify DN response callback
--
--    Client   - The LDAP client
--    ID       - The message ID
--    Result   - The result code
--    Matched  - The matched name
--    Message  - The diagnostic message
--    Referral - The referral list
--
-- The default implementation does nothing.
--
   procedure Receive_Modify_DN_Response
             (  Client   : in out LDAP_Client;
                ID       : Integer_32;
                Result   : Result_Code;
                Matched  : Distinguished_Name;
                Message  : String;
                Referral : Values_List
             );
--
-- Receive_Search_Done_Response -- Received search done response
--                                 callback
--    Client   - The LDAP client
--    ID       - The message ID
--    Result   - The result code
--    Matched  - The matched name
--    Message  - The diagnostic message
--    Referral - The referral list
--
-- The default implementation does nothing.
--
   procedure Receive_Search_Done_Response
             (  Client   : in out LDAP_Client;
                ID       : Integer_32;
                Result   : Result_Code;
                Matched  : Distinguished_Name;
                Message  : String;
                Referral : Values_List
             );
--
-- Receive_Search_Entry_Response -- Received search entry response
--                                  callback
--    Client     - The LDAP client
--    ID         - The message ID
--    Name       - Found distinguished name
--    Attributes - Found attributes
--
-- The default implementation does nothing.
--
   procedure Receive_Search_Entry_Response
             (  Client     : in out LDAP_Client;
                ID         : Integer_32;
                Name       : Distinguished_Name;
                Attributes : Attributes_List
             );
--
-- Receive_Search_Reference_Response -- Received search reference
--                                      response callback
--    Client - The LDAP client
--    ID     - The message ID
--    URIs   - The references list
--
-- The default implementation does nothing.
--
   procedure Receive_Search_Reference_Response
             (  Client : in out LDAP_Client;
                ID     : Integer_32;
                URIs   : Values_List
             );
--
-- Send_Abandon -- Send add request
--
--    Client - The LDAP client
--    ID     - The message ID
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Abandon
             (  Client : in out LDAP_Client;
                ID     : Integer_32
             );
--
-- Send_Add -- Send add request
--
--    Client     - The LDAP client
--    Name       - The entry to add
--    Attributes - The list of attribute description with values list
--  [ Timeout ]  - The timeout, asynchronous if absent
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Add
             (  Client     : in out LDAP_Client;
                Name       : Distinguished_Name;
                Attributes : Attributes_List;
                Timeout    : Duration := Duration'First
             );
--
-- Send_Bind -- Send bind request (simple authentication)
--
--    Client    - The LDAP client
--    Name      - The user name
--    Password  - The password
--  [ Timeout ] - The timeout, asynchronous if absent
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Bind
             (  Client   : in out LDAP_Client;
                Name     : Distinguished_Name;
                Password : String;
                Timeout  : Duration := Duration'First
             );
--
-- Send_Bind -- Send bind request (SASL authentication)
--
--    Client      - The LDAP client
--    Name        - The name to bind
--    Mechanism   - The SASL mechanism to use
--    Credentials - The credentials if needed
--  [ Timeout ]   - The timeout, asynchronous if absent
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Bind
             (  Client      : in out LDAP_Client;
                Name        : Distinguished_Name;
                Mechanism   : String;
                Credentials : String   := "";
                Timeout     : Duration := Duration'First
             );
--
-- Send_Compare -- Send compare request
--
--    Client      - The LDAP client
--    Name        - The entry name
--    Description - The attribute description
--    Value       - The attribute value
--  [ Timeout ]   - The timeout, asynchronous if absent
--
-- Returns :
--
--    The result True/False
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Compare
             (  Client      : in out LDAP_Client;
                Name        : Distinguished_Name;
                Description : String;
                Value       : String
             );
   function Send_Compare
            (  Client      : LDAP_Client;
               Name        : Distinguished_Name;
               Description : String;
               Value       : String;
               Timeout     : Duration
            )  return Boolean;
--
-- Send_Delete -- Send delete request
--
--    Client    - The LDAP client
--    Name      - The entry name
--  [ Timeout ] - The timeout, asynchronous if absent
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Delete
             (  Client  : in out LDAP_Client;
                Name    : Distinguished_Name;
                Timeout : Duration := Duration'First
             );
--
-- Send_Extended -- Send extended request
--
--    Client    - The LDAP client
--    Name      - The name
--    Value     - The value
--  [ Timeout ] - The timeout, asynchronous if absent
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Extended
             (  Client  : in out LDAP_Client;
                Name    : Object_Identifier;
                Value   : String;
                Timeout : Duration := Duration'First
             );
--
-- Send_Modify -- Send modify request
--
--    Client    - The LDAP client
--    Name      - The object to modify
--    Update    - The updates list
--  [ Timeout ] - The timeout, asynchronous if absent
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Modify
             (  Client  : in out LDAP_Client;
                Name    : Distinguished_Name;
                Update  : Updates_List;
                Timeout : Duration := Duration'First
             );
--
-- Send_Modify_DN -- Send modify DN request
--
--    Client       - The LDAP client
--    Name         - The entry to modify
--    New_RDN      - The new relative distinguished name
--    Delete_RDN   - Delete any attribute values in the original
--    New_Superior - The new parent for the entry
--  [ Timeout ]    - The timeout, asynchronous if absent
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Modify_DN
             (  Client       : in out LDAP_Client;
                Name         : Distinguished_Name;
                New_RDN      : Distinguished_Name;
                Delete_RDN   : Boolean;
                New_Superior : Distinguished_Name;
                Timeout      : Duration := Duration'First
             );
   procedure Send_Modify_DN
             (  Client     : in out LDAP_Client;
                Name       : Distinguished_Name;
                New_RDN    : Distinguished_Name;
                Delete_RDN : Boolean;
                Timeout    : Duration := Duration'First
             );
--
-- Send_Search -- Send search request
--
--    Client        - The LDAP client
--    Name          - To start the search at
--    Filter        - The filter to set
--    Must_Exist    - Raise End_Error if the object does not exist
--    Scope         - Of the search relatively to Base_Object
--    Aliasing_Mode - The method to handle aliases
--    Size_Limit    - The maximum number of result entries
--    Time_Limit    - For processing the request
--    Types_Only    - Only include attribute descriptions
--  [ Timeout ]     - The timeout, asynchronous if absent
--
-- When the synchronous with timeout is used,  the procedure awaits  all
-- exchange  to complete until the server sends search result done.  The
-- callbacks
--
--    Receive_Search_Entry_Response and
--    Receive_Search_Reference_Response
--
-- are called to accumulate intermediate server responses.
--
-- Returns :
--
--    The accumulated search result
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    End_Error    - No object and Must_Exist is True
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Search
             (  Client        : in out LDAP_Client;
                Name          : Distinguished_Name;
                Filter        : Search_Filter;
                Must_Exist    : Boolean          := False;
                Scope         : Scope_Type       := Whole_Subtree_Scope;
                Aliasing_Mode : Dereference_Type := Deref_Always;
                Size_Limit    : Integer_32       := 0;
                Time_Limit    : Duration         := 0.0;
                Types_Only    : Boolean          := False;
                Timeout       : Duration         := Duration'First
             );
   function Send_Search
            (  Client        : LDAP_Client;
               Name          : Distinguished_Name;
               Filter        : Search_Filter;
               Must_Exist    : Boolean          := False;
               Scope         : Scope_Type       := Whole_Subtree_Scope;
               Aliasing_Mode : Dereference_Type := Deref_Always;
               Size_Limit    : Integer_32       := 0;
               Time_Limit    : Duration         := 0.0;
               Types_Only    : Boolean          := False;
               Timeout       : Duration
            )  return Search_Result;
--
-- Send_Unbind -- Send unbind request
--
--    Client - The LDAP client
--
-- Exceptions :
--
--    Socket_Error - I/O error
--    Status_Error - The connection is down
--    Data_Error   - Protocol errors
--    LDAP_Error   - Execution error
--
   procedure Send_Unbind (Client : in out LDAP_Client);
--
-- Trace -- Tracing
--
--    Client  - The LDAP client
--    Message - To write into the trace
--
   procedure Trace
             (  Client  : in out LDAP_Client;
                Message : String
             );
--
-- Wait -- For connection object ready
--
--    Client    - The LDAP client
--    Connected - Require connection
--    Timeout   - For the operation
--
-- This procedure is called to wait for the session to become ready  for
-- another request.
--
-- Exceptions :
--
--    Cancel_Error  - Waiting canceled by a call to Cancel
--    Socket_Error  - Socket error
--    Status_Error  - Connection failure, e.g. attempts exhausted
--    Timeout_Error - Timeout expired
--
   procedure Wait
             (  Client    : in out LDAP_Client;
                Connected : Boolean;
                Timeout   : Duration := Duration'Last
             );

private
   type Distinguished_Name_Ptr is access Distinguished_Name;
   type Search_Entry (Count : Natural) is new Object.Entity with record
      Name       : Distinguished_Name_Ptr;
      Attributes : Attributes_List (Count);
   end record;
   type Search_Entry_Ptr is access Search_Entry'Class;
   procedure Finalize (Item : in out Search_Entry);
   package Search_Entry_Handles is
      new Object.Handle (Search_Entry, Search_Entry_Ptr);
   function Create
            (  Name       : Distinguished_Name;
               Attributes : Attributes_List
            )  return Search_Entry_Handles.Handle;
   type Search_Entry_Array is
      array (Positive range <>) of Search_Entry_Handles.Handle;
   type Search_Result
        (  Entries_Count    : Natural;
           References_Count : Natural
        )  is
   record
      Entries    : Search_Entry_Array (1..Entries_Count);
      References : Values_List (References_Count);
   end record;

   protected type Event_Type
                  (  Client : access LDAP_Client'Class
                  )  is
      entry Cancel;
      entry Do_Notification (ID : Integer_32; Choice : Positive);
      procedure Release;
      entry Released;
      entry Start_Notification (ID : Integer_32; Choice : Positive);
      entry Start_Wait         (ID : Integer_32);
      entry Stop_Notification  (ID : Integer_32; Choice : Positive);
      procedure Stop_Wait;
      entry Seize;
      entry Wait (Connected : in out Boolean);
      procedure Set;
   private
      entry Lounge;
      entry Wait_Lounge (Boolean) (ID : Integer_32);

      Ready : Boolean := False;
      Down  : Boolean := True;
      Owner : Task_ID := Null_Task_ID;
      Count : Natural := 0;

      Current_Lounge   : Boolean := False;
      Requests_Count   : Natural := 0;
      Current_ID       : Integer_32;
      Current_Response : Integer;
   end Event_Type;

   procedure Connected (Client : in out LDAP_Client);
   procedure End_Of_Query (Client : in out LDAP_Client);
   procedure Released (Client : in out LDAP_Client);

   procedure Write
             (  Stream : access Root_Stream_Type'Class;
                Item   : Event_Type
             );
   for Event_Type'Write use Write;

   type LDAP_Client is new LDAP_Peer with record
      Event    : aliased Event_Type (LDAP_Client'Unchecked_Access);
      Sequence : Integer_32 := 1;
   end record;
   procedure Check_Result
             (  Client : in out LDAP_Client;
                Result : LDAP_Result'Class
             );
   procedure Process_Packet (Client : in out LDAP_Client);

   type Holder (Event : access Event_Type) is
      new Ada.Finalization.Limited_Controlled with null record;
   procedure Finalize  (Lock : in out Holder);
   procedure Initialize (Lock : in out Holder);

end GNAT.Sockets.Connection_State_Machine.LDAP.Client;