tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / extensions / source / config / ldap / ldapaccess.hxx
blob36a0708b1eb718def48fe9ca5893469127a8eccc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <sal/config.h>
24 #include <map>
26 #ifdef _WIN32
27 #if !defined WIN32_LEAN_AND_MEAN
28 #define WIN32_LEAN_AND_MEAN
29 #endif
30 #include <windows.h>
31 #include <winldap.h>
32 #else // !defined _WIN32
33 #include <ldap.h>
34 #endif // _WIN32
36 #include <com/sun/star/ldap/LdapGenericException.hpp>
38 #include <com/sun/star/lang/IllegalArgumentException.hpp>
40 namespace extensions::config::ldap
42 namespace uno = css::uno;
43 namespace lang = css::lang;
44 namespace ldap = css::ldap;
46 struct LdapUserProfile;
48 /** Struct containing the information on LDAP connection */
49 struct LdapDefinition
51 /** LDAP server name */
52 OUString mServer;
53 /** LDAP server port number */
54 sal_Int32 mPort;
55 /** Repository base DN */
56 OUString mBaseDN;
57 /** DN to use for "anonymous" connection */
58 OUString mAnonUser;
59 /** Credentials to use for "anonymous" connection */
60 OUString mAnonCredentials;
61 /** User Entity Object Class */
62 OUString mUserObjectClass;
63 /** User Entity Unique Attribute */
64 OUString mUserUniqueAttr;
66 LdapDefinition()
67 : mPort(0)
72 typedef std::map<OUString, OUString> LdapData; // key/value pairs
74 /** Class encapsulating all LDAP functionality */
75 class LdapConnection
77 friend struct LdapMessageHolder;
79 public:
80 /** Default constructor */
81 LdapConnection()
82 : mConnection(nullptr)
83 , mLdapDefinition()
86 /** Destructor, releases the connection */
87 ~LdapConnection();
88 /** Make connection to LDAP server
89 @throws ldap::LdapConnectionException
90 @throws ldap::LdapGenericException
92 void connectSimple(const LdapDefinition& aDefinition);
94 /**
95 Gets LdapUserProfile from LDAP repository for specified user
96 @param aUser name of logged on user
97 @param aUserProfileMap Map containing LDAP->00o mapping
98 @param aUserProfile struct for holding OOo values
100 @throws css::ldap::LdapGenericException
101 if an LDAP error occurs.
103 void getUserProfile(const OUString& aUser, LdapData* data);
105 /** finds DN of user
106 @return DN of User
107 @throws lang::IllegalArgumentException
108 @throws ldap::LdapConnectionException
109 @throws ldap::LdapGenericException
111 OUString findUserDn(const OUString& aUser);
113 private:
114 /// @throws ldap::LdapConnectionException
115 void initConnection();
116 void disconnect();
118 Indicates whether the connection is in a valid state.
119 @return sal_True if connection is valid, sal_False otherwise
121 bool isValid() const { return mConnection != nullptr; }
123 /// @throws ldap::LdapConnectionException
124 /// @throws ldap::LdapGenericException
125 void connectSimple();
127 /** LDAP connection object */
128 LDAP* mConnection;
129 LdapDefinition mLdapDefinition;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */