UDK 3.2.7 C/C++ API Reference

osl/security.hxx

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 
00020 #ifndef _OSL_SECURITY_HXX_
00021 #define _OSL_SECURITY_HXX_
00022 
00023 #include <rtl/ustring.hxx>
00024 
00025 #ifndef _OSL_SECURITY_DECL_HXX
00026 #   include <osl/security_decl.hxx>
00027 #endif
00028 
00029 namespace osl
00030 {
00031 
00032 inline Security::Security()
00033 {
00034     m_handle = osl_getCurrentSecurity();
00035 }
00036 
00037 inline Security::~Security()
00038 {
00039     osl_freeSecurityHandle(m_handle);
00040 }
00041 
00042 inline sal_Bool Security::logonUser(const rtl::OUString& strName,
00043                                     const rtl::OUString& strPasswd)
00044 {
00045     osl_freeSecurityHandle(m_handle);
00046 
00047     m_handle = 0;
00048 
00049     return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle)
00050             == osl_Security_E_None);
00051 }
00052 
00053 inline sal_Bool Security::logonUser( const rtl::OUString& strName,
00054                                       const rtl::OUString& strPasswd,
00055                                       const rtl::OUString& strFileServer )
00056 {
00057     osl_freeSecurityHandle(m_handle);
00058 
00059     m_handle = NULL;
00060 
00061     return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle)
00062             == osl_Security_E_None);
00063 }
00064 
00065 inline sal_Bool Security::getUserIdent( rtl::OUString& strIdent) const
00066 {
00067     return osl_getUserIdent( m_handle, &strIdent.pData );
00068 }
00069 
00070 
00071 inline sal_Bool Security::getUserName( rtl::OUString& strName ) const
00072 {
00073     return osl_getUserName( m_handle, &strName.pData );
00074 }
00075 
00076 
00077 inline sal_Bool Security::getHomeDir( rtl::OUString& strDirectory) const
00078 {
00079     return osl_getHomeDir(m_handle, &strDirectory.pData );
00080 }
00081 
00082 
00083 inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const
00084 {
00085     return osl_getConfigDir( m_handle, &strDirectory.pData );
00086 }
00087 
00088 inline sal_Bool Security::isAdministrator() const
00089 {
00090     return osl_isAdministrator(m_handle);
00091 }
00092 
00093 inline oslSecurity Security::getHandle() const
00094 {
00095     return m_handle;
00096 }
00097 
00098 
00099 }
00100 
00101 #endif  // _OSL_SECURITY_HXX_
00102 
00103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines