| Index: base/win/win_util.cc
|
| diff --git a/base/win/win_util.cc b/base/win/win_util.cc
|
| index 3b7d3195ac6c0b2622ef39c263cf2479d6c4606f..838891102df72b0f6dc1dcddf7cd5777b9922a0d 100644
|
| --- a/base/win/win_util.cc
|
| +++ b/base/win/win_util.cc
|
| @@ -10,6 +10,7 @@
|
| #include <shobjidl.h> // Must be before propkey.
|
| #include <initguid.h>
|
| #include <inspectable.h>
|
| +#include <mdmregistration.h>
|
| #include <propkey.h>
|
| #include <propvarutil.h>
|
| #include <psapi.h>
|
| @@ -535,6 +536,31 @@ bool IsEnrolledToDomain() {
|
| return g_domain_state == ENROLLED;
|
| }
|
|
|
| +bool IsDeviceRegisteredWithMdm() {
|
| + using IsDeviceRegisteredWithManagementFunction =
|
| + decltype(&IsDeviceRegisteredWithManagement);
|
| +
|
| + static IsDeviceRegisteredWithManagementFunction fn = nullptr;
|
| + if (!fn) {
|
| + HMODULE mdm_dll = ::LoadLibrary(L"MDMRegistration.dll");
|
| + fn = reinterpret_cast<IsDeviceRegisteredWithManagementFunction>(
|
| + ::GetProcAddress(mdm_dll, "IsDeviceRegisteredWithManagement"));
|
| + if (!fn) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + BOOL is_managed = false;
|
| + HRESULT hr = fn(&is_managed, 0, nullptr);
|
| + LOG(ERROR) << "*** rogerta: IsDeviceRegisteredWithMdm: "
|
| + << (bool)((hr) && is_managed);
|
| + return SUCCEEDED(hr) && is_managed;
|
| +}
|
| +
|
| +bool IsEnterpriseUser() {
|
| + return IsEnrolledToDomain() || IsDeviceRegisteredWithMdm();
|
| +}
|
| +
|
| void SetDomainStateForTesting(bool state) {
|
| g_domain_state = state ? ENROLLED : NOT_ENROLLED;
|
| }
|
|
|