1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
27 #if !defined WIN32_LEAN_AND_MEAN
28 #define WIN32_LEAN_AND_MEAN
32 #else // !defined _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 */
51 /** LDAP server name */
53 /** LDAP server port number */
55 /** Repository base DN */
57 /** DN to use for "anonymous" connection */
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
;
72 typedef std::map
<OUString
, OUString
> LdapData
; // key/value pairs
74 /** Class encapsulating all LDAP functionality */
77 friend struct LdapMessageHolder
;
80 /** Default constructor */
82 : mConnection(nullptr)
86 /** Destructor, releases the connection */
88 /** Make connection to LDAP server
89 @throws ldap::LdapConnectionException
90 @throws ldap::LdapGenericException
92 void connectSimple(const LdapDefinition
& aDefinition
);
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
);
107 @throws lang::IllegalArgumentException
108 @throws ldap::LdapConnectionException
109 @throws ldap::LdapGenericException
111 OUString
findUserDn(const OUString
& aUser
);
114 /// @throws ldap::LdapConnectionException
115 void initConnection();
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 */
129 LdapDefinition mLdapDefinition
;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */