File indexing completed on 2024-12-22 04:59:50
0001 /* 0002 SPDX-FileCopyrightText: 2004-2007 Szombathelyi György <gyurco@freemail.hu> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #pragma once 0008 0009 #include <KIO/AuthInfo> 0010 #include <KIO/WorkerBase> 0011 0012 #include "kldapcore/ldapconnection.h" 0013 #include "kldapcore/ldapcontrol.h" 0014 #include "kldapcore/ldapdefs.h" 0015 #include "kldapcore/ldapdn.h" 0016 #include "kldapcore/ldapoperation.h" 0017 #include "kldapcore/ldapurl.h" 0018 0019 class LDAPProtocol : public KIO::WorkerBase 0020 { 0021 public: 0022 LDAPProtocol(const QByteArray &protocol, const QByteArray &pool, const QByteArray &app); 0023 ~LDAPProtocol() override; 0024 0025 void setHost(const QString &host, quint16 port, const QString &user, const QString &pass) override; 0026 0027 [[nodiscard]] KIO::WorkerResult openConnection() override; 0028 void closeConnection() override; 0029 0030 KIO::WorkerResult get(const QUrl &url) override; 0031 KIO::WorkerResult stat(const QUrl &url) override; 0032 KIO::WorkerResult listDir(const QUrl &url) override; 0033 KIO::WorkerResult del(const QUrl &url, bool isfile) override; 0034 KIO::WorkerResult put(const QUrl &url, int permissions, KIO::JobFlags flags) override; 0035 0036 private: 0037 QByteArray mProtocol; 0038 KLDAPCore::LdapConnection mConn; 0039 KLDAPCore::LdapOperation mOp; 0040 KLDAPCore::LdapServer mServer; 0041 bool mConnected = false; 0042 0043 void controlsFromMetaData(KLDAPCore::LdapControls &serverctrls, KLDAPCore::LdapControls &clientctrls); 0044 void LDAPEntry2UDSEntry(const KLDAPCore::LdapDN &dn, KIO::UDSEntry &entry, const KLDAPCore::LdapUrl &usrc, bool dir = false); 0045 0046 KIO::WorkerResult LDAPErr(int err = KLDAP_SUCCESS); 0047 KIO::WorkerResult changeCheck(const KLDAPCore::LdapUrl &url); 0048 };