bump product version to 4.1.6.2
[LibreOffice.git] / extensions / source / config / ldap / ldapaccess.hxx
blobf2378d080b57f9f8833da2cad6decf863eaf9c09
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 #ifndef EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_
21 #define EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_
23 #include "sal/config.h"
25 #include <map>
27 #ifdef WNT
28 #include <windows.h>
29 #include <winldap.h>
30 #else // !defined WNT
31 #include <ldap.h>
32 #endif // WNT
34 #include <com/sun/star/ldap/LdapGenericException.hpp>
36 #include <com/sun/star/ldap/LdapConnectionException.hpp>
37 #include <com/sun/star/lang/IllegalArgumentException.hpp>
38 #include <osl/module.h>
40 namespace extensions { namespace config { namespace ldap {
42 namespace uno = css::uno ;
43 namespace lang = css::lang ;
44 namespace ldap = css::ldap ;
45 //------------------------------------------------------------------------------
46 struct LdapUserProfile;
48 //------------------------------------------------------------------------------
49 /** Struct containing the information on LDAP connection */
50 struct LdapDefinition
52 /** LDAP server name */
53 OUString mServer ;
54 /** LDAP server port number */
55 sal_Int32 mPort ;
56 /** Repository base DN */
57 OUString mBaseDN ;
58 /** DN to use for "anonymous" connection */
59 OUString mAnonUser ;
60 /** Credentials to use for "anonymous" connection */
61 OUString mAnonCredentials ;
62 /** User Entity Object Class */
63 OUString mUserObjectClass;
64 /** User Entity Unique Attribute */
65 OUString mUserUniqueAttr;
66 } ;
68 typedef std::map< OUString, OUString > LdapData; // key/value pairs
70 /** Class encapulating all LDAP functionality */
71 class LdapConnection
73 friend struct LdapMessageHolder;
74 public:
76 /** Default constructor */
77 LdapConnection(void) : mConnection(NULL),mLdapDefinition() {}
78 /** Destructor, releases the connection */
79 ~LdapConnection(void) ;
80 /** Make connection to LDAP server */
81 void connectSimple(const LdapDefinition& aDefinition)
82 throw (ldap::LdapConnectionException,
83 ldap::LdapGenericException);
85 /**
86 Gets LdapUserProfile from LDAP repository for specified user
87 @param aUser name of logged on user
88 @param aUserProfileMap Map containing LDAP->00o mapping
89 @param aUserProfile struct for holding OOo values
91 @throws com::sun::star::ldap::LdapGenericException
92 if an LDAP error occurs.
94 void getUserProfile(const OUString& aUser, LdapData * data)
95 throw (lang::IllegalArgumentException,
96 ldap::LdapConnectionException,
97 ldap::LdapGenericException);
99 /** finds DN of user
100 @return DN of User
102 OUString findUserDn(const OUString& aUser)
103 throw (lang::IllegalArgumentException,
104 ldap::LdapConnectionException,
105 ldap::LdapGenericException);
107 private:
109 void initConnection()
110 throw (ldap::LdapConnectionException);
111 void disconnect();
113 Indicates whether the connection is in a valid state.
114 @return sal_True if connection is valid, sal_False otherwise
116 bool isValid(void) const { return mConnection != NULL ; }
118 void connectSimple()
119 throw (ldap::LdapConnectionException,
120 ldap::LdapGenericException);
122 /** LDAP connection object */
123 LDAP* mConnection ;
124 LdapDefinition mLdapDefinition;
127 //------------------------------------------------------------------------------
128 }} }
130 #endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */