UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 00029 #ifndef _OSL_SECURITY_HXX_ 00030 #define _OSL_SECURITY_HXX_ 00031 00032 #include <rtl/ustring.hxx> 00033 00034 #ifndef _OSL_SECURITY_DECL_HXX 00035 # include <osl/security_decl.hxx> 00036 #endif 00037 00038 namespace osl 00039 { 00040 00041 inline Security::Security() 00042 { 00043 m_handle = osl_getCurrentSecurity(); 00044 } 00045 00046 inline Security::~Security() 00047 { 00048 osl_freeSecurityHandle(m_handle); 00049 } 00050 00051 inline sal_Bool Security::logonUser(const rtl::OUString& strName, 00052 const rtl::OUString& strPasswd) 00053 { 00054 osl_freeSecurityHandle(m_handle); 00055 00056 m_handle = 0; 00057 00058 return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle) 00059 == osl_Security_E_None); 00060 } 00061 00062 inline sal_Bool Security::logonUser( const rtl::OUString& strName, 00063 const rtl::OUString& strPasswd, 00064 const rtl::OUString& strFileServer ) 00065 { 00066 osl_freeSecurityHandle(m_handle); 00067 00068 m_handle = NULL; 00069 00070 return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle) 00071 == osl_Security_E_None); 00072 } 00073 00074 inline sal_Bool Security::getUserIdent( rtl::OUString& strIdent) const 00075 { 00076 return osl_getUserIdent( m_handle, &strIdent.pData ); 00077 } 00078 00079 00080 inline sal_Bool Security::getUserName( rtl::OUString& strName ) const 00081 { 00082 return osl_getUserName( m_handle, &strName.pData ); 00083 } 00084 00085 00086 inline sal_Bool Security::getHomeDir( rtl::OUString& strDirectory) const 00087 { 00088 return osl_getHomeDir(m_handle, &strDirectory.pData ); 00089 } 00090 00091 00092 inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const 00093 { 00094 return osl_getConfigDir( m_handle, &strDirectory.pData ); 00095 } 00096 00097 inline sal_Bool Security::isAdministrator() const 00098 { 00099 return osl_isAdministrator(m_handle); 00100 } 00101 00102 inline oslSecurity Security::getHandle() const 00103 { 00104 return m_handle; 00105 } 00106 00107 00108 } 00109 00110 #endif // _OSL_SECURITY_HXX_ 00111 00112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */