| OLD | NEW |
| (Empty) |
| 1 // Copyright 2004-2009 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 // This class finds out different user rights on the system. | |
| 17 // For example it can find out if the user is an administrator. | |
| 18 | |
| 19 #ifndef OMAHA_BASE_USER_RIGHTS_H_ | |
| 20 #define OMAHA_BASE_USER_RIGHTS_H_ | |
| 21 | |
| 22 #include <windows.h> | |
| 23 #include <atlsecurity.h> | |
| 24 #include "base/basictypes.h" | |
| 25 | |
| 26 namespace omaha { | |
| 27 | |
| 28 class UserRights { | |
| 29 public: | |
| 30 | |
| 31 // Returns true if token is a member of the local Administrators group. | |
| 32 static bool TokenIsAdmin(HANDLE token); | |
| 33 | |
| 34 // Returns true if the user belongs to the local Administrators group. | |
| 35 static bool UserIsAdmin(); | |
| 36 | |
| 37 // Returns true if the user belongs to the Users group. | |
| 38 static bool UserIsUser(); | |
| 39 | |
| 40 // Returns true if the user belongs to the Power User group. | |
| 41 static bool UserIsPowerUser(); | |
| 42 | |
| 43 // Returns true if the user is a Guest. | |
| 44 static bool UserIsGuest(); | |
| 45 | |
| 46 // Returns true if the owner of the current process has a restricted token. | |
| 47 static bool UserIsRestricted(); | |
| 48 | |
| 49 // Returns true if the owner of the current process runs under low or | |
| 50 // untrusted integrity on Vista. | |
| 51 static bool UserIsLowOrUntrustedIntegrity(); | |
| 52 | |
| 53 // Returns true if the owner of the current process has an interactive | |
| 54 // session: console, terminal services, or fast user switching. | |
| 55 static HRESULT UserIsLoggedOnInteractively(bool* is_logged_on); | |
| 56 | |
| 57 // Gets the COM caller's impersonation token. If not in an inter-apartment COM | |
| 58 // call, returns the current process token. | |
| 59 static HRESULT GetCallerToken(CAccessToken* token); | |
| 60 | |
| 61 static bool VerifyCallerIsAdmin(); | |
| 62 | |
| 63 static bool VerifyCallerIsSystem(); | |
| 64 | |
| 65 // Returns true if the owner of the current process is the primary logon token | |
| 66 // for the current interactive session: console, terminal services, or fast | |
| 67 // user switching. | |
| 68 static bool BelongsToGroup(HANDLE token, int group_id); | |
| 69 | |
| 70 private: | |
| 71 DISALLOW_IMPLICIT_CONSTRUCTORS(UserRights); | |
| 72 }; | |
| 73 | |
| 74 } // namespace omaha | |
| 75 | |
| 76 #endif // OMAHA_BASE_USER_RIGHTS_H_ | |
| 77 | |
| OLD | NEW |