| OLD | NEW |
| (Empty) |
| 1 // Copyright 2004-2010 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 // | |
| 16 // Class UserInfo: Information related to the current user or other users on | |
| 17 // this machine. | |
| 18 // | |
| 19 // TODO(omaha): seems we can merge this module with user_rights. | |
| 20 | |
| 21 #ifndef OMAHA_COMMON_USER_INFO_H__ | |
| 22 #define OMAHA_COMMON_USER_INFO_H__ | |
| 23 | |
| 24 #include <windows.h> | |
| 25 #include <atlsecurity.h> | |
| 26 #include <atlstr.h> | |
| 27 | |
| 28 namespace omaha { | |
| 29 | |
| 30 namespace user_info { | |
| 31 | |
| 32 // Gets the user name, domain, and the SID associated with the access token | |
| 33 // of the current process. | |
| 34 HRESULT GetProcessUser(CString* name, CString* domain, CString* sid); | |
| 35 | |
| 36 // Gets SID associated with the access token of the current process. | |
| 37 HRESULT GetProcessUserSid(CSid* sid); | |
| 38 | |
| 39 // Gets the user SID associated with the access token of the current thread if | |
| 40 // the thread is impersonating. If the thread is not impersonating, the API | |
| 41 // fails with ERROR_NO_TOKEN. | |
| 42 HRESULT GetThreadUserSid(CString* sid); | |
| 43 | |
| 44 // Gets the user SID associated with the access token of the current thread if | |
| 45 // the thread is impersonating. Otherwise, gets the SID associated with the | |
| 46 // access token of the current process. | |
| 47 HRESULT GetEffectiveUserSid(CString* sid); | |
| 48 | |
| 49 // TODO(omaha): deprecate weird API. | |
| 50 // Looks at the current user SID and checks if it's the same as the | |
| 51 // LocalSystem user. | |
| 52 HRESULT IsLocalSystemUser(bool* is_local_system, | |
| 53 CString* user_sid); // optional. | |
| 54 | |
| 55 // Returns true if the caller's impersonation or process access token user | |
| 56 // is LOCAL_SYSTEM. | |
| 57 bool IsRunningAsSystem(); | |
| 58 | |
| 59 // Returns true if the current thread is impersonating. | |
| 60 bool IsThreadImpersonating(); | |
| 61 | |
| 62 } // namespace user_info | |
| 63 | |
| 64 } // namespace omaha | |
| 65 | |
| 66 #endif // OMAHA_COMMON_USER_INFO_H__ | |
| OLD | NEW |