LDAPRequest.h 2.54 KB
Newer Older
Ralf Haferkamp's avatar
Ralf Haferkamp committed
1
// $OpenLDAP$
2
/*
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
3
 * Copyright 2000-2021 The OpenLDAP Foundation, All Rights Reserved.
4
5
6
7
8
9
10
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */


#ifndef LDAP_REQUEST_H
#define LDAP_REQUEST_H

11
12
13
#include <LDAPConstraints.h>
#include <LDAPAsynConnection.h>
#include <LDAPMessageQueue.h>
14
15
16

class LDAPUrl;

Ralf Haferkamp's avatar
Ralf Haferkamp committed
17
18
19
20
21
/**
 * For internal use only
 * 
 * Each request that is sent to a LDAP-server by this library is
 * represented by a special object that contains the parameters and some
Josh Soref's avatar
Josh Soref committed
22
 * other info of the request. This virtual class is the common base class
Ralf Haferkamp's avatar
Ralf Haferkamp committed
23
24
 * for these specialized request classes.
 */
25
26
27
28
29
30
31
32
33
34
class LDAPRequest{

    public :
        static const int BIND=0;
        static const int UNBIND=2;
        static const int SEARCH=3;
        static const int MODIFY=7;
        static const int ADD=8;
		static const int DELETE=10;
        static const int COMPARE=14;
35
36
37
38
39
40
41
42
43

        LDAPRequest(const LDAPRequest& req);
        LDAPRequest(LDAPAsynConnection* conn, 
                const LDAPConstraints* cons, bool isReferral=false,
                const LDAPRequest* parent=0);
        virtual ~LDAPRequest();
        
        const LDAPConstraints* getConstraints() const;
        const LDAPAsynConnection* getConnection() const;
Ralf Haferkamp's avatar
Ralf Haferkamp committed
44
        virtual LDAPMsg *getNextMessage() const;
45
46
47
        int getType()const;
        int getMsgID() const;
        int getHopCount() const;
Ralf Haferkamp's avatar
Ralf Haferkamp committed
48
49
50
51
52

        /**
         * @return The LDAPRequest that has created this object. Or 0 if
         * this object was not created by another request.
         */
53
54
        const LDAPRequest* getParent() const;

Ralf Haferkamp's avatar
Ralf Haferkamp committed
55
56
57
58
        /**
         * @return true if this object was created during the automatic
         * chasing of referrals. Otherwise false
         */
59
        bool isReferral() const;
Ralf Haferkamp's avatar
Ralf Haferkamp committed
60
        
61
        void unbind() const; 
Ralf Haferkamp's avatar
Ralf Haferkamp committed
62
63
64
65
66

        /**
         * This method encodes the request an calls the apprpriate
         * functions of the C-API to send the Request to a LDAP-Server
         */
67
        virtual LDAPMessageQueue* sendRequest()=0;
Ralf Haferkamp's avatar
Ralf Haferkamp committed
68
        virtual LDAPRequest* followReferral(LDAPMsg* ref);
Ralf Haferkamp's avatar
Ralf Haferkamp committed
69
70
71
72
73

        /**
         * Compare this request with another on. And returns true if they
         * have the same parameters.
         */
74
        virtual bool equals(const LDAPRequest* req) const;
Ralf Haferkamp's avatar
Ralf Haferkamp committed
75

76
77
78
79
80
81
82
83
84
85
86
        bool isCycle() const;
        
    protected :
        bool m_isReferral;
        int m_requestType;
        LDAPConstraints *m_cons;
        LDAPAsynConnection *m_connection;
        const LDAPRequest* m_parent;
        int m_hopCount;
        int m_msgID;  //the associated C-API Message ID
        LDAPRequest();
87
88
89
};
#endif //LDAP_REQUEST_H