summaryrefslogtreecommitdiffstats
path: root/tdeioslave/ldap/tdeio_ldap.h
blob: e3909048126fbe376f30e2898b3d69bf075465fd (plain)
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
#ifndef __LDAP_H__
#define __LDAP_H__

#include <tqstring.h>
#include <tqvaluelist.h>

#include <tdeio/slavebase.h>
#include <tdeio/authinfo.h>

#define LDAP_DEPRECATED 1 /* Needed for ldap_simple_bind_s with openldap >= 2.3.x */
#include <lber.h>
#include <ldap.h>
#include <tdeabc/ldapurl.h>

class LDAPProtocol : public TDEIO::SlaveBase
{
  public:
    LDAPProtocol( const TQCString &protocol, const TQCString &pool, const TQCString &app );
    virtual ~LDAPProtocol();
    
    virtual void setHost( const TQString& host, int port,
                          const TQString& user, const TQString& pass );

    virtual void openConnection();
    virtual void closeConnection();
    
    virtual void get( const KURL& url );
    virtual void stat( const KURL& url );
    virtual void listDir( const KURL& url );
    virtual void del( const KURL& url, bool isfile );
    virtual void put( const KURL& url, int permissions, bool overwrite, bool resume );

    int saslInteract( void *in );

  private:

    TQString mHost;
    int mPort;
    TQString mUser;
    TQString mPassword;
    LDAP *mLDAP;
    int mVer, mSizeLimit, mTimeLimit;
    bool mTLS;
    bool mAuthSASL;
    TQString mMech,mRealm,mBindName;
    bool mCancel, mFirstAuth;
    
    void controlsFromMetaData( LDAPControl ***serverctrls, 
      LDAPControl ***clientctrls );
    void addControlOp( LDAPControl ***pctrls, const TQString &oid,
      const TQByteArray &value, bool critical );
    void addModOp( LDAPMod ***pmods, int mod_type, 
      const TQString &attr, const TQByteArray &value );
    void LDAPEntry2UDSEntry( const TQString &dn, TDEIO::UDSEntry &entry, 
      const TDEABC::LDAPUrl &usrc, bool dir=false );
    int asyncSearch( TDEABC::LDAPUrl &usrc );
    
    TQCString LDAPEntryAsLDIF( LDAPMessage *msg );
    void LDAPErr( const KURL &url, int err = LDAP_SUCCESS );
    void changeCheck( TDEABC::LDAPUrl &url );

    void fillAuthInfo( TDEIO::AuthInfo &info );
};

#endif