1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _OSL_SECURITY_H_ 29 #define _OSL_SECURITY_H_ 30 31 #include <rtl/ustring.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 typedef enum { 38 osl_Security_E_None, 39 osl_Security_E_UserUnknown, 40 osl_Security_E_WrongPassword, 41 osl_Security_E_Unknown, 42 osl_Security_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM 43 } oslSecurityError; 44 45 /** Process handle 46 @see osl_loginUser 47 @see osl_freeSecurityHandle 48 @see osl_executeProcess 49 */ 50 typedef void* oslSecurity; 51 52 /** Create a security handle for the current user. 53 @return a security handle or NULL on failure. 54 @see osl_freeSecurityHandle 55 @see osl_executeProcess 56 @see osl_executeApplication 57 */ 58 oslSecurity SAL_CALL osl_getCurrentSecurity(void); 59 60 /** Create a security handle for the denoted user. 61 Try to log in the user on the local system. 62 @param strzUserName [in] denotes the name of the user to logg in. 63 @param strPasswd [in] the password for this user. 64 @param pSecurity [out] returns the security handle if user could be logged in. 65 @return osl_Security_E_None if user could be logged in, otherwise an error-code. 66 @see osl_freeSecurityHandle 67 @see osl_executeProcess 68 @see osl_executeApplication 69 */ 70 oslSecurityError SAL_CALL osl_loginUser( 71 rtl_uString *strUserName, 72 rtl_uString *strPasswd, 73 oslSecurity *pSecurity 74 ); 75 76 /** Create a security handle for the denoted user. 77 Try to log in the user on the denoted file server. On success the homedir will be 78 the maped drive on this server. 79 @param strUserName [in] denotes the name of the user to logg in. 80 @param strPasswd [in] the password for this user. 81 @param strFileServer [in] denotes the file server on wich the user is logged in. 82 @param pSecurity [out] returns the security handle if user could be logged in. 83 @return osl_Security_E_None if user could be logged in, otherwise an error-code. 84 @see osl_freeSecurityHandle 85 @see osl_executeProcess 86 @see osl_executeApplication 87 */ 88 oslSecurityError SAL_CALL osl_loginUserOnFileServer( 89 rtl_uString *strUserName, 90 rtl_uString *strPasswd, 91 rtl_uString *strFileServer, 92 oslSecurity *pSecurity 93 ); 94 95 /** Query if the user who is denotes by this security has administrator rigths. 96 @param Security [in] the security handle for th user. 97 @return True, if the user has adminsitrator rights, otherwise false. 98 */ 99 sal_Bool SAL_CALL osl_isAdministrator(oslSecurity Security); 100 101 /** Free the security handle, created by osl_loginUser or osl_getCurrentSecurity. 102 @param Security [in] the security handle. 103 @see osl_loginUser 104 */ 105 void SAL_CALL osl_freeSecurityHandle(oslSecurity Security); 106 107 /** Get the login ident for the user of this security handle. 108 @param Security [in] the security handle. 109 @param strIdent [out] the string that receives the ident on success. 110 @return True, if the security handle is valid, otherwise False. 111 */ 112 sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent); 113 114 /** Get the login name for the user of this security handle. 115 @param Security [in] the security handle. 116 @param pszName [out] the string that receives the user name on success. 117 @return True, if the security handle is valid, otherwise False. 118 */ 119 sal_Bool SAL_CALL osl_getUserName(oslSecurity Security, rtl_uString **strName); 120 121 /** Get the home directory of the user of this security handle. 122 @param Security [in] the security handle. 123 @param strDirectory [out] the string that receives the directory path on success. 124 @return True, if the security handle is valid, otherwise False. 125 */ 126 sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **strDirectory); 127 128 /** Get the directory for configuration data of the user of this security handle. 129 @param Security [in] the security handle. 130 @param strDirectory [out] the string that receives the directory path on success. 131 @return True, if the security handle is valid, otherwise False. 132 */ 133 sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **strDirectory); 134 135 136 /** Load Profile of the User 137 Implemented just for Windows 138 @param oslSecurity Security [in] previously fetch Security of the User 139 @return True if the Profile could successfully loaded, False otherwise. 140 */ 141 142 sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security); 143 144 145 /** Unload a User Profile 146 Implemented just for Windows 147 @param oslSecurity Security [in] previously fetch Security of the User 148 @return nothing is returned! 149 */ 150 151 void SAL_CALL osl_unloadUserProfile(oslSecurity Security); 152 153 #ifdef __cplusplus 154 } 155 #endif 156 157 #endif /* _OSL_SECURITY_H_ */ 158 159