LibreOffice Module extensions (master) 1
ldapaccess.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <map>
25
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
35
36#include <com/sun/star/ldap/LdapGenericException.hpp>
37
38#include <com/sun/star/lang/IllegalArgumentException.hpp>
39
41{
42namespace uno = css::uno;
43namespace lang = css::lang;
44namespace ldap = css::ldap;
45
46struct LdapUserProfile;
47
50{
52 OUString mServer;
54 sal_Int32 mPort;
56 OUString mBaseDN;
58 OUString mAnonUser;
65
67 : mPort(0)
68 {
69 }
70};
71
72typedef std::map<OUString, OUString> LdapData; // key/value pairs
73
76{
77 friend struct LdapMessageHolder;
78
79public:
82 : mConnection(nullptr)
84 {
85 }
92 void connectSimple(const LdapDefinition& aDefinition);
93
103 void getUserProfile(const OUString& aUser, LdapData* data);
104
111 OUString findUserDn(const OUString& aUser);
112
113private:
115 void initConnection();
116 void disconnect();
121 bool isValid() const { return mConnection != nullptr; }
122
125 void connectSimple();
126
130};
131}
132
133/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Class encapsulating all LDAP functionality.
Definition: ldapaccess.hxx:76
LDAP * mConnection
LDAP connection object.
Definition: ldapaccess.hxx:128
void getUserProfile(const OUString &aUser, LdapData *data)
Gets LdapUserProfile from LDAP repository for specified user.
Definition: ldapaccess.cxx:172
bool isValid() const
Indicates whether the connection is in a valid state.
Definition: ldapaccess.hxx:121
OUString findUserDn(const OUString &aUser)
finds DN of user
Definition: ldapaccess.cxx:227
~LdapConnection()
Destructor, releases the connection.
Definition: ldapaccess.cxx:48
std::map< OUString, OUString > LdapData
Definition: ldapaccess.hxx:72
Struct containing the information on LDAP connection.
Definition: ldapaccess.hxx:50
OUString mAnonUser
DN to use for "anonymous" connection.
Definition: ldapaccess.hxx:58
OUString mServer
LDAP server name.
Definition: ldapaccess.hxx:52
OUString mUserObjectClass
User Entity Object Class.
Definition: ldapaccess.hxx:62
OUString mUserUniqueAttr
User Entity Unique Attribute.
Definition: ldapaccess.hxx:64
OUString mAnonCredentials
Credentials to use for "anonymous" connection.
Definition: ldapaccess.hxx:60
OUString mBaseDN
Repository base DN.
Definition: ldapaccess.hxx:56
sal_Int32 mPort
LDAP server port number.
Definition: ldapaccess.hxx:54