1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_ENTERPRISE_UTIL_H_
6 #define BASE_ENTERPRISE_UTIL_H_
7 
8 #include "base/base_export.h"
9 #include "build/build_config.h"
10 
11 namespace base {
12 
13 // Returns true if an outside entity manages the current machine. This includes
14 // but is not limited to the presence of user accounts from a centralized
15 // directory or the presence of dynamically updatable machine policies from an
16 // outside administrator.
17 BASE_EXPORT bool IsMachineExternallyManaged();
18 
19 #if defined(OS_APPLE)
20 
21 // Returns true if the device is being managed by an MDM system. Uses an old API
22 // not intended for the purpose.
23 enum class MacDeviceManagementStateOld {
24   kFailureAPIUnavailable = 0,
25   kFailureUnableToParseResult = 1,
26   kNoEnrollment = 2,
27   kMDMEnrollment = 3,
28 
29   kMaxValue = kMDMEnrollment
30 };
31 BASE_EXPORT MacDeviceManagementStateOld IsDeviceRegisteredWithManagementOld();
32 
33 // Returns the state of the management of the device. Uses a new API so results
34 // aren't always available. For more details, this is documented at
35 // https://blog.fleetsmith.com/what-is-user-approved-mdm-uamdm/ .
36 
37 // These values are persisted to logs. Entries must not be renumbered and
38 // numeric values must never be reused.
39 enum class MacDeviceManagementStateNew {
40   kFailureAPIUnavailable = 0,
41   kFailureUnableToParseResult = 1,
42   kNoEnrollment = 2,
43   kLimitedMDMEnrollment = 3,
44   kFullMDMEnrollment = 4,
45   kDEPMDMEnrollment = 5,
46 
47   kMaxValue = kDEPMDMEnrollment
48 };
49 BASE_EXPORT MacDeviceManagementStateNew IsDeviceRegisteredWithManagementNew();
50 
51 // Returns whether the device and/or the current user is enrolled to a domain.
52 struct DeviceUserDomainJoinState {
53   bool device_joined;
54   bool user_joined;
55 };
56 BASE_EXPORT DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain();
57 
58 #endif  // OS_APPLE
59 
60 }  // namespace base
61 
62 #endif  // BASE_ENTERPRISE_UTIL_H_
63