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 .
20 #ifndef INCLUDED_OSL_SECURITY_H
21 #define INCLUDED_OSL_SECURITY_H
23 #include "sal/config.h"
25 #include "rtl/ustring.h"
26 #include "sal/saldllapi.h"
34 osl_Security_E_UserUnknown
,
35 osl_Security_E_WrongPassword
,
36 osl_Security_E_Unknown
,
37 osl_Security_E_FORCE_EQUAL_SIZE
= SAL_MAX_ENUM
42 @see osl_freeSecurityHandle
43 @see osl_executeProcess
45 typedef void* oslSecurity
;
47 /** Create a security handle for the current user.
48 @return a security handle or NULL on failure.
49 @see osl_freeSecurityHandle
50 @see osl_executeProcess
51 @see osl_executeApplication
53 SAL_DLLPUBLIC oslSecurity SAL_CALL
osl_getCurrentSecurity(void);
56 Create a security handle for the denoted user.
57 Try to log in the user on the local system.
58 @param[in] strUserName denotes the name of the user to log in.
59 @param[in] strPasswd the password for this user.
60 @param[out] pSecurity returns the security handle if user could be logged in.
61 @return osl_Security_E_None if user could be logged in, otherwise an error-code.
62 @see osl_freeSecurityHandle
63 @see osl_executeProcess
64 @see osl_executeApplication
66 SAL_DLLPUBLIC oslSecurityError SAL_CALL
osl_loginUser(
67 rtl_uString
*strUserName
,
68 rtl_uString
*strPasswd
,
69 oslSecurity
*pSecurity
72 /** Create a security handle for the denoted user.
73 Try to log in the user on the denoted file server. On success the homedir will be
74 the mapped drive on this server.
75 @param[in] strUserName denotes the name of the user to log in.
76 @param[in] strPasswd the password for this user.
77 @param[in] strFileServer denotes the file server on which the user is logged in.
78 @param[out] pSecurity returns the security handle if user could be logged in.
79 @return osl_Security_E_None if user could be logged in, otherwise an error-code.
80 @see osl_freeSecurityHandle
81 @see osl_executeProcess
82 @see osl_executeApplication
84 SAL_DLLPUBLIC oslSecurityError SAL_CALL
osl_loginUserOnFileServer(
85 rtl_uString
*strUserName
,
86 rtl_uString
*strPasswd
,
87 rtl_uString
*strFileServer
,
88 oslSecurity
*pSecurity
91 /** Query if the user who is denotes by this security has administrator rights.
92 @param[in] Security the security handle for th user.
93 @return True, if the user has administrator rights, otherwise false.
95 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_isAdministrator(
96 oslSecurity Security
);
98 /** Free the security handle, created by osl_loginUser or osl_getCurrentSecurity.
99 @param[in] Security the security handle.
102 SAL_DLLPUBLIC
void SAL_CALL
osl_freeSecurityHandle(
103 oslSecurity Security
);
105 /** Get the login ident for the user of this security handle.
106 @param[in] Security the security handle.
107 @param[out] strIdent the string that receives the ident on success.
108 @return True, if the security handle is valid, otherwise False.
110 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getUserIdent(
111 oslSecurity Security
, rtl_uString
**strIdent
);
113 /** Get the login name for the user of this security handle.
114 @param[in] Security the security handle.
115 @param[out] strName the string that receives the user name on success.
116 @return True, if the security handle is valid, otherwise False.
118 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getUserName(
119 oslSecurity Security
, rtl_uString
**strName
);
121 /** Get the login name for the user of this security handle,
122 excluding the domain name on Windows.
123 @param[in] Security the security handle.
124 @param[out] strName the string that receives the user name on success.
125 @return True, if the security handle is valid, otherwise False.
126 @since LibreOffice 5.2
128 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getShortUserName(
129 oslSecurity Security
, rtl_uString
**strName
);
131 /** Get the home directory of the user of this security handle.
132 @param[in] Security the security handle.
133 @param[out] strDirectory the string that receives the directory path on success.
134 @return True, if the security handle is valid, otherwise False.
136 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getHomeDir(
137 oslSecurity Security
, rtl_uString
**strDirectory
);
139 /** Get the directory for configuration data of the user of this security handle.
140 @param[in] Security the security handle.
141 @param[out] strDirectory the string that receives the directory path on success.
142 @return True, if the security handle is valid, otherwise False.
144 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getConfigDir(
145 oslSecurity Security
, rtl_uString
**strDirectory
);
148 /** Load Profile of the User
149 Implemented just for Windows
150 @param[in] Security previously fetch Security of the User
151 @return True if the Profile could successfully loaded, False otherwise.
154 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_loadUserProfile(
155 oslSecurity Security
);
158 /** Unload a User Profile
159 Implemented just for Windows
160 @param[in] Security previously fetch Security of the User
161 @return nothing is returned!
164 SAL_DLLPUBLIC
void SAL_CALL
osl_unloadUserProfile(
165 oslSecurity Security
);
171 #endif // INCLUDED_OSL_SECURITY_H
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */