1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ldapuserprof.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROF_HXX_
32 #define EXTENSIONS_CONFIG_LDAP_LDAPUSERPROF_HXX_
34 #include "wrapldapinclude.hxx"
35 #include <rtl/ustring.hxx>
36 #include <rtl/string.hxx>
38 #ifndef VECTOR_INCLUDED
39 #define VECTOR_INCLUDED
41 #endif // VECTOR_INCLUDED
46 #endif // SET_INCLUDED
49 namespace extensions
{ namespace config
{ namespace ldap
{
51 /** Struct containing the data associated to a UserProfile */
52 struct LdapUserProfile
{
53 /** Struct defining an entry in the profile */
55 rtl::OUString mAttribute
;
56 rtl::OUString mValue
;
58 /** List of attribute/value pairs */
59 std::vector
<ProfileEntry
> mProfile
;
61 typedef std::vector
<ProfileEntry
>::const_iterator Iterator
;
64 /** Provider of UserProfile mapping services */
65 class LdapUserProfileMap
68 /** Default constructor, doesn't do much. */
69 LdapUserProfileMap() : mAttributes(NULL
) {}
71 ~LdapUserProfileMap() ;
74 Fills the map using a string description of the mapping.
75 Each possible UserProfile attribute is mapped to a list
76 of LDAP attributes, in order of priority.
77 The entry is formatted as:
78 <UP Attribute>=<LDAP Attr1>,...,<LDAP AttrN>
80 @param aMap string description of the mapping
82 void source(const rtl::OString
& aMap
) ;
84 Returns an array of all the LDAP attribute names that may
85 be relevant for UserProfile mapping.
87 @return array of LDAP attribute names
89 const sal_Char
**getLdapAttributes(void) const { return mAttributes
; }
91 Returns the component name that holds the data
92 when presented to the outside.
94 @return component name
96 const rtl::OUString
& getComponentName(void) const {
97 return mComponentName
;
100 Returns the group name that holds the data when
101 presented to the outside world.
105 const rtl::OUString
& getGroupName(void) const {
109 Struct defining the mapping between UserProfile attributes
110 and LDAP ones. It also serves as a crude "schema" of the
111 UserProfile component, as the list of profile elements
112 is the list of properties in the component and the presence
113 or absence of LDAP mapping indicates whether the property
114 should be made writable or kept read-only.
117 /** Name of the UserProfile element */
118 rtl::OString mProfileElement
;
119 /** Corresponding LDAP attributes in order of priority */
120 std::vector
<rtl::OString
> mLdapAttributes
;
122 /** Utility to fill the mapping from a <Prof>=<Ldap1>;...;<LdapN>
124 sal_Bool
parse(const rtl::OString
& aDescription
) ;
129 Maps an LDAP entry to a UserProfile.
131 @param aConnection LDAP connection to the repository
132 @param aEntry entry containing the data
133 @param aProfile user profile struct to fill up
135 void ldapToUserProfile(LDAP
*aConnection
,
137 LdapUserProfile
& aProfile
) const ;
140 /** Contains the mapping entries */
141 std::vector
<Mapping
> mMapping
;
142 /** Contains the LDAP attributes used in a NULL terminated array */
143 const sal_Char
**mAttributes
;
144 /** User profile component name */
145 rtl::OUString mComponentName
;
146 /** User profile storage group name */
147 rtl::OUString mGroupName
;
150 Adds a new mapping entry to the list, and collects the
151 LDAP attributes involved in the mapping.
153 @param aMappingDescription string describing the mapping
154 @param aLdapAttributes collection of LDAP attributes
155 @param aPrefix common prefix to the attributes
156 containing the component and group
157 name, used for validation
159 void addNewMapping(const rtl::OString
& aMappingDescription
,
160 std::set
<rtl::OString
>& aLdapAttributes
,
161 rtl::OString
& aPrefix
) ;
164 } } } // extensions.config.ldap
166 #endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROF_HXX_