update dev300-m58
[ooovba.git] / vos / source / security.cxx
blobee7945c27f677e6eda6011d6dd0a5677843c44f1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: security.cxx,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
32 #include <vos/security.hxx>
33 #include <vos/diagnose.hxx>
35 using namespace vos;
37 /////////////////////////////////////////////////////////////////////////////
38 // Object super class
40 VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OSecurity, vos), VOS_NAMESPACE(OSecurity, vos), VOS_NAMESPACE(OObject, vos), 0);
42 OSecurity::OSecurity()
44 m_oslSecurity = osl_getCurrentSecurity();
47 OSecurity::~OSecurity()
49 osl_freeSecurityHandle(m_oslSecurity);
52 sal_Bool OSecurity::logonUser(const rtl::OUString& strName,
53 const rtl::OUString& strPasswd)
55 osl_freeSecurityHandle(m_oslSecurity);
57 m_oslSecurity = NULL;
59 return (osl_loginUser( strName.pData, strPasswd.pData, &m_oslSecurity)
60 == osl_Security_E_None);
64 sal_Bool OSecurity::logonUser( const rtl::OUString& strName,
65 const rtl::OUString& strPasswd,
66 const rtl::OUString& strFileServer )
68 osl_freeSecurityHandle(m_oslSecurity);
70 m_oslSecurity = NULL;
72 return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_oslSecurity)
73 == osl_Security_E_None);
77 sal_Bool OSecurity::getUserIdent( rtl::OUString& strIdent) const
79 VOS_ASSERT(m_oslSecurity);
81 return osl_getUserIdent( m_oslSecurity, &strIdent.pData );
85 sal_Bool OSecurity::getUserName( rtl::OUString& strName ) const
87 VOS_ASSERT(m_oslSecurity);
89 return osl_getUserName( m_oslSecurity, &strName.pData );
93 sal_Bool OSecurity::getHomeDir( rtl::OUString& strDirectory) const
95 VOS_ASSERT(m_oslSecurity);
97 return osl_getHomeDir(m_oslSecurity, &strDirectory.pData );
101 sal_Bool OSecurity::getConfigDir( rtl::OUString& strDirectory ) const
103 VOS_ASSERT(m_oslSecurity);
105 return osl_getConfigDir( m_oslSecurity, &strDirectory.pData );
108 sal_Bool OSecurity::isAdministrator() const
110 VOS_ASSERT(m_oslSecurity);
112 return osl_isAdministrator(m_oslSecurity);
115 OSecurity::operator oslSecurity() const
117 return m_oslSecurity;