xref: /aosp_15_r20/external/cronet/base/enterprise_util_win.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker // Copyright 2019 The Chromium Authors
2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file.
4*6777b538SAndroid Build Coastguard Worker 
5*6777b538SAndroid Build Coastguard Worker #include "base/enterprise_util.h"
6*6777b538SAndroid Build Coastguard Worker 
7*6777b538SAndroid Build Coastguard Worker #include "base/win/win_util.h"
8*6777b538SAndroid Build Coastguard Worker #include "base/win/windows_version.h"
9*6777b538SAndroid Build Coastguard Worker 
10*6777b538SAndroid Build Coastguard Worker namespace base {
11*6777b538SAndroid Build Coastguard Worker 
IsManagedDevice()12*6777b538SAndroid Build Coastguard Worker bool IsManagedDevice() {
13*6777b538SAndroid Build Coastguard Worker   // Legacy domain join does not actually guarantee that the device is managed,
14*6777b538SAndroid Build Coastguard Worker   // however there is no API that can be used to determine if any group policies
15*6777b538SAndroid Build Coastguard Worker   // are actually being applied. As such, for these devices we need to assume
16*6777b538SAndroid Build Coastguard Worker   // they are managed.
17*6777b538SAndroid Build Coastguard Worker   // In addition, simply being joined to AAD does not mean the device is being
18*6777b538SAndroid Build Coastguard Worker   // managed by the AAD tenant, so checking for AAD join is not included here.
19*6777b538SAndroid Build Coastguard Worker   return base::win::IsEnrolledToDomain() ||
20*6777b538SAndroid Build Coastguard Worker          base::win::IsDeviceRegisteredWithManagement();
21*6777b538SAndroid Build Coastguard Worker }
22*6777b538SAndroid Build Coastguard Worker 
IsEnterpriseDevice()23*6777b538SAndroid Build Coastguard Worker bool IsEnterpriseDevice() {
24*6777b538SAndroid Build Coastguard Worker   // Both legacy domain join and AAD join represent machine-wide enterprise
25*6777b538SAndroid Build Coastguard Worker   // join.
26*6777b538SAndroid Build Coastguard Worker   return base::win::IsEnrolledToDomain() || base::win::IsJoinedToAzureAD();
27*6777b538SAndroid Build Coastguard Worker }
28*6777b538SAndroid Build Coastguard Worker 
29*6777b538SAndroid Build Coastguard Worker }  // namespace base
30