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_HXX
21 #define INCLUDED_OSL_SECURITY_HXX
23 #include <rtl/ustring.hxx>
24 #include <osl/security_decl.hxx>
29 inline Security::Security()
31 m_handle
= osl_getCurrentSecurity();
34 inline Security::~Security()
36 osl_freeSecurityHandle(m_handle
);
39 inline bool Security::logonUser(const rtl::OUString
& strName
,
40 const rtl::OUString
& strPasswd
)
42 osl_freeSecurityHandle(m_handle
);
46 return (osl_loginUser( strName
.pData
, strPasswd
.pData
, &m_handle
)
47 == osl_Security_E_None
);
50 inline bool Security::logonUser( const rtl::OUString
& strName
,
51 const rtl::OUString
& strPasswd
,
52 const rtl::OUString
& strFileServer
)
54 osl_freeSecurityHandle(m_handle
);
58 return (osl_loginUserOnFileServer(strName
.pData
, strPasswd
.pData
, strFileServer
.pData
, &m_handle
)
59 == osl_Security_E_None
);
62 inline bool Security::getUserIdent( rtl::OUString
& strIdent
) const
64 return osl_getUserIdent( m_handle
, &strIdent
.pData
);
68 inline bool Security::getUserName( rtl::OUString
& strName
) const
70 return osl_getUserName( m_handle
, &strName
.pData
);
74 inline bool Security::getHomeDir( rtl::OUString
& strDirectory
) const
76 return osl_getHomeDir(m_handle
, &strDirectory
.pData
);
80 inline bool Security::getConfigDir( rtl::OUString
& strDirectory
) const
82 return osl_getConfigDir( m_handle
, &strDirectory
.pData
);
85 inline bool Security::isAdministrator() const
87 return osl_isAdministrator(m_handle
);
90 inline oslSecurity
Security::getHandle() const
98 #endif // INCLUDED_OSL_SECURITY_HXX
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */