refresh date: 2026-09-25 robots: noindex
说明
使用 chrome.enterprise.deviceAttributes API 读取设备属性。注意:此 API 仅适用于由企业政策强制安装的扩展程序。
权限
enterprise.deviceAttributes可用性
方法
getDeviceAnnotatedLocation()
chrome.enterprise.deviceAttributes.getDeviceAnnotatedLocation(
callback?: function,
): Promise<string>
提取管理员标注的位置。如果当前用户不属于任何组织,或者管理员未设置任何带注释的位置,则返回空字符串。
参数
-
callback
函数可选
callback参数如下所示:(annotatedLocation: string) => void
-
annotatedLocation
字符串
-
返回
-
Promise<string>
Chrome 96 及更高版本返回一个 Promise,该 Promise 会解析为设备的带注释位置。
只有 Manifest V3 及更高版本支持 Promise,其他平台需要使用回调。
getDeviceAssetId()
chrome.enterprise.deviceAttributes.getDeviceAssetId(
callback?: function,
): Promise<string>
提取管理员标注的资产 ID。如果当前用户未关联,或者管理员未设置资产 ID,则返回空字符串。
参数
-
callback
函数可选
callback参数如下所示:(assetId: string) => void
-
assetId
字符串
-
返回
-
Promise<string>
Chrome 96 及更高版本返回一个 Promise,该 Promise 会解析为设备的资产 ID。
只有 Manifest V3 及更高版本支持 Promise,其他平台需要使用回调。
getDeviceHostname()
chrome.enterprise.deviceAttributes.getDeviceHostname(
callback?: function,
): Promise<string>
提取由 DeviceHostnameTemplate 政策设置的设备主机名。如果当前用户不属于任何组织,或者企业政策未设置任何主机名,则返回空字符串。
参数
-
callback
函数可选
callback参数如下所示:(hostname: string) => void
-
主机名
字符串
-
返回
-
Promise<string>
Chrome 96 及更高版本返回一个 Promise,该 Promise 会解析为主机名。
只有 Manifest V3 及更高版本支持 Promise,其他平台需要使用回调。
getDeviceSerialNumber()
chrome.enterprise.deviceAttributes.getDeviceSerialNumber(
callback?: function,
): Promise<string>
提取设备的序列号。请注意,此 API 的用途是管理设备(例如,为设备级证书生成证书签名请求)。未经设备管理员同意,不得使用此 API 跟踪设备。如果当前用户未关联,则返回空字符串。
参数
-
callback
函数可选
callback参数如下所示:(serialNumber: string) => void
-
serialNumber
字符串
-
返回
-
Promise<string>
Chrome 96 及更高版本返回一个 Promise,该 Promise 会解析为设备的序列号。
只有 Manifest V3 及更高版本支持 Promise,其他平台需要使用回调。
getDirectoryDeviceId()
chrome.enterprise.deviceAttributes.getDirectoryDeviceId(
callback?: function,
): Promise<string>
提取目录 API 的设备标识符的值,该值由服务器生成,用于标识设备的云记录,以便在云目录 API 中进行查询。如果当前用户未关联,则返回空字符串。
参数
-
callback
函数可选
callback参数如下所示:(deviceId: string) => void
-
deviceId
字符串
-
返回
-
Promise<string>
Chrome 96 及更高版本返回一个 Promise,该 Promise 会解析为 Directory API 的设备标识符。
只有 Manifest V3 及更高版本支持 Promise,其他平台需要使用回调。