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_DECL_HXX
21 #define INCLUDED_OSL_SECURITY_DECL_HXX
23 #include <rtl/ustring.hxx>
24 # include <osl/security.h>
29 /** Encapsulate security information for one user.
30 A object of this class is used to execute a process with the rights an
31 security options of a specified user.
32 @see Process::executeProcess
43 /** get the security information for one user.
44 The underlying operating system is asked for this information.
45 @param[in] strName denotes the name of the user
46 @param[in] strPasswd denotes the password of this user
47 @retval True, if the specified user is known by the underlying operating system
48 @retval False unknown user
50 inline bool SAL_CALL
logonUser(const rtl::OUString
& strName
,
51 const rtl::OUString
& strPasswd
);
53 /** get the security information for one user.
56 This method will try to login the user at the denoted file server.
57 If a network resource named \\server\username exists and this resource
58 could be connected by this user, the methos will return true and getHomeDir
59 will return \\server\username.
62 @param[in] strName denotes the name of the user
63 @param[in] strPasswd denotes the password of this user
64 @param[in] strFileServer denotes the file server to login to
66 @retval True if the specified user is known by the file server and they
68 @retval False if the user is not known by the file server
70 inline bool SAL_CALL
logonUser(const rtl::OUString
& strName
,
71 const rtl::OUString
& strPasswd
,
72 const rtl::OUString
& strFileServer
);
74 /** get the ident of the logged in user.
75 @param[out] strIdent is the OUString which returns the name
77 @retval True if any user is successfully logged in
78 @retval False no user logged in
80 inline bool SAL_CALL
getUserIdent( rtl::OUString
& strIdent
) const;
82 /** get the name of the logged in user.
83 @param[out] strName is the OUString which returns the name
84 @param[in] bIncludeDomain Include the Domain name (like "ORG\username"). Affects Windows only.
85 This parameter is available since LibreOffice 5.2.
87 @retval True if any user is successfully logged in
88 @retval False if no user is logged in
90 inline bool SAL_CALL
getUserName( rtl::OUString
& strName
, bool bIncludeDomain
=true ) const;
92 /** get the home directory of the logged in user.
93 @param[out] strDirectory is the OUString which returns the directory name
95 @retval True if any user is successfully logged in
96 @retval False if user is not logged in
98 inline bool SAL_CALL
getHomeDir( rtl::OUString
& strDirectory
) const;
100 /** get the directory for configuration data of the logged in user.
101 @param[out] strDirectory is the OUString which returns the directory name
103 @retval True if any user is successfully logged in
104 @retval False if user is not logged in
106 inline bool SAL_CALL
getConfigDir( rtl::OUString
& strDirectory
) const;
108 /** Query if the user who is logged in has administrator rights.
109 @retval True if the user has administrator rights
110 @retval False if the user does not have admin rights
112 inline bool SAL_CALL
isAdministrator() const;
114 /** Returns the underlying oslSecurity handle
116 inline oslSecurity
getHandle() const;
122 #endif // INCLUDED_OSL_SECURITY_DECL_HXX
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */