1# @ohos.enterprise.adminManager (Enterprise Device Management) (System API) 2 3The **adminManager** module provides enterprise device management capabilities so that devices have the custom capabilities required in enterprise settings. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> - The APIs of this module are available only to [device administrator applications](../../mdm/mdm-kit-guide.md#introduction). 10> 11> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.enterprise.adminManager](js-apis-enterprise-adminManager.md). 12 13## Modules to Import 14 15```ts 16import { adminManager } from '@kit.MDMKit'; 17``` 18 19## adminManager.enableAdmin 20 21enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<void>): void 22 23Enables a device administrator application for the current user. The super device administrator application can be activated only by the administrator. This API uses an asynchronous callback to return the result. 24 25**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 26 27**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 28 29 30 31**Model restriction**: This API can be used only in the stage model. 32 33**Parameters** 34 35| Name | Type | Mandatory | Description | 36| -------------- | ----------------------------------- | ---- | ------------------ | 37| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application to enable. | 38| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | 39| type | [AdminType](#admintype) | Yes | Type of the device administrator application to enable. | 40| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 41 42**Error codes** 43 44For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 45 46| ID| Error Message | 47| ------- | --------------------------------------------------------------- | 48| 9200003 | The administrator ability component is invalid. | 49| 9200004 | Failed to activate the administrator application of the device. | 50| 9200007 | The system ability works abnormally. | 51| 201 | Permission verification failed. The application does not have the permission required to call the API. | 52| 202 | Permission verification failed. A non-system application calls a system API. | 53| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 54 55**Example** 56 57```ts 58import { Want } from '@kit.AbilityKit'; 59let wantTemp: Want = { 60 bundleName: 'com.example.myapplication', 61 abilityName: 'EntryAbility', 62}; 63let enterpriseInfo: adminManager.EnterpriseInfo = { 64 name: 'enterprise name', 65 description: 'enterprise description' 66} 67 68adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_SUPER, (err) => { 69 if (err) { 70 console.error(`Failed to enable admin. Code: ${err.code}, message: ${err.message}`); 71 return; 72 } 73 console.info('Succeeded in enabling admin'); 74}); 75``` 76 77## adminManager.enableAdmin 78 79enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<void>): void 80 81Enables a device administrator application for the specified user. The super device administrator application can be activated only by the administrator. This API uses an asynchronous callback to return the result. 82 83**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 84 85**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 86 87 88 89**Model restriction**: This API can be used only in the stage model. 90 91**Parameters** 92 93| Name | Type | Mandatory | Description | 94| -------------- | ----------------------------------- | ---- | ---------------------------- | 95| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application to enable. | 96| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | 97| type | [AdminType](#admintype) | Yes | Type of the device administrator application to enable. | 98| userId | number | Yes | User ID, which must be greater than or equal to 0.<br>The default value is the user ID of the caller. | 99| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 100 101**Error codes** 102 103For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 104 105| ID| Error Message | 106| ------- | --------------------------------------------------------------- | 107| 9200003 | The administrator ability component is invalid. | 108| 9200004 | Failed to activate the administrator application of the device. | 109| 9200007 | The system ability works abnormally. | 110| 201 | Permission verification failed. The application does not have the permission required to call the API. | 111| 202 | Permission verification failed. A non-system application calls a system API. | 112| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 113 114**Example** 115 116```ts 117import { Want } from '@kit.AbilityKit'; 118let wantTemp: Want = { 119 bundleName: 'com.example.myapplication', 120 abilityName: 'EntryAbility', 121}; 122let enterpriseInfo: adminManager.EnterpriseInfo = { 123 name: 'enterprise name', 124 description: 'enterprise description' 125} 126 127adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100, (err) => { 128 if (err) { 129 console.error(`Failed to enable admin. Code: ${err.code}, message: ${err.message}`); 130 return; 131 } 132 console.info('Succeeded in enabling admin'); 133}); 134``` 135 136## adminManager.enableAdmin 137 138enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<void> 139 140Enables a device administrator application for the current or specified user. The super device administrator application can be activated only by the administrator. This API uses a promise to return the result. 141 142**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 143 144**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 145 146 147 148**Model restriction**: This API can be used only in the stage model. 149 150**Parameters** 151 152| Name | Type | Mandatory | Description | 153| -------------- | ----------------------------------- | ---- | ---------------------------- | 154| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application to enable. | 155| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information of the device administrator application. | 156| type | [AdminType](#admintype) | Yes | Type of the device administrator application to enable. | 157| userId | number | No | User ID, which must be greater than or equal to 0.<br>- If **userId** is passed in, this API applies to the specified user.<br>- If **userId** is not passed in, this API applies to the current user.| 158 159**Return value** 160 161| Type | Description | 162| ----------------- | ----------------- | 163| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 164 165**Error codes** 166 167For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 168 169| ID| Error Message | 170| ------- | --------------------------------------------------------------- | 171| 9200003 | The administrator ability component is invalid. | 172| 9200004 | Failed to activate the administrator application of the device. | 173| 9200007 | The system ability works abnormally. | 174| 201 | Permission verification failed. The application does not have the permission required to call the API. | 175| 202 | Permission verification failed. A non-system application calls a system API. | 176| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 177 178**Example** 179 180```ts 181import { Want } from '@kit.AbilityKit'; 182import { BusinessError } from '@kit.BasicServicesKit'; 183let wantTemp: Want = { 184 bundleName: 'com.example.myapplication', 185 abilityName: 'EntryAbility', 186}; 187let enterpriseInfo: adminManager.EnterpriseInfo = { 188 name: 'enterprise name', 189 description: 'enterprise description' 190} 191 192adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100).catch( 193 (err: BusinessError) => { 194 console.error(`Failed to enable admin. Code: ${err.code}, message: ${err.message}`); 195 }); 196``` 197 198## adminManager.disableAdmin 199 200disableAdmin(admin: Want, callback: AsyncCallback\<void>): void 201 202Disables a common administrator application for the current user. This API uses an asynchronous callback to return the result. 203 204**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 205 206**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 207 208 209 210**Model restriction**: This API can be used only in the stage model. 211 212**Parameters** 213 214| Name | Type | Mandatory | Description | 215| -------- | ----------------------------------- | ---- | ------------------- | 216| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Common administrator application to disable. | 217| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 218 219**Error codes** 220 221For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 222 223| ID| Error Message | 224| ------- | ----------------------------------------------------------------- | 225| 9200005 | Failed to deactivate the administrator application of the device. | 226| 201 | Permission verification failed. The application does not have the permission required to call the API. | 227| 202 | Permission verification failed. A non-system application calls a system API. | 228| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 229 230**Example** 231 232```ts 233import { Want } from '@kit.AbilityKit'; 234let wantTemp: Want = { 235 bundleName: 'bundleName', 236 abilityName: 'abilityName', 237}; 238 239adminManager.disableAdmin(wantTemp, (err) => { 240 if (err) { 241 console.error(`Failed to disable admin. Code: ${err.code}, message: ${err.message}`); 242 return; 243 } 244 console.info('Succeeded in disabling admin'); 245}); 246``` 247 248## adminManager.disableAdmin 249 250disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void 251 252Disables a common administrator application for the specified user. This API uses an asynchronous callback to return the result. 253 254**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 255 256**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 257 258 259 260**Model restriction**: This API can be used only in the stage model. 261 262**Parameters** 263 264| Name | Type | Mandatory | Description | 265| -------- | ----------------------------------- | ---- | ---------------------------- | 266| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Common administrator application to disable. | 267| userId | number | Yes | User ID, which must be greater than or equal to 0.<br>The default value is the user ID of the caller. | 268| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 269 270**Error codes** 271 272For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 273 274| ID| Error Message | 275| ------- | ----------------------------------------------------------------- | 276| 9200005 | Failed to deactivate the administrator application of the device. | 277| 201 | Permission verification failed. The application does not have the permission required to call the API. | 278| 202 | Permission verification failed. A non-system application calls a system API. | 279| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 280 281**Example** 282 283```ts 284import { Want } from '@kit.AbilityKit'; 285let wantTemp: Want = { 286 bundleName: 'bundleName', 287 abilityName: 'abilityName', 288}; 289 290adminManager.disableAdmin(wantTemp, 100, (err) => { 291 if (err) { 292 console.error(`Failed to disable admin. Code: ${err.code}, message: ${err.message}`); 293 return; 294 } 295 console.info('Succeeded in disabling admin'); 296}); 297``` 298 299## adminManager.disableSuperAdmin 300 301disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void 302 303Disables a super administrator application for the administrator based on **bundleName**. This API uses an asynchronous callback to return the result. 304 305**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 306 307**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 308 309 310 311**Model restriction**: This API can be used only in the stage model. 312 313**Parameters** 314 315| Name | Type | Mandatory | Description | 316| ---------- | ----------------------- | ---- | ------------------- | 317| bundleName | String | Yes | Bundle name of the super administrator application to disable. | 318| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 319 320**Error codes** 321 322For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 323 324| ID| Error Message | 325| ------- | ----------------------------------------------------------------- | 326| 9200005 | Failed to deactivate the administrator application of the device. | 327| 201 | Permission verification failed. The application does not have the permission required to call the API. | 328| 202 | Permission verification failed. A non-system application calls a system API. | 329| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 330 331**Example** 332 333```ts 334import { Want } from '@kit.AbilityKit'; 335let bundleName: string = 'com.example.myapplication'; 336 337adminManager.disableSuperAdmin(bundleName, (err) => { 338 if (err) { 339 console.error(`Failed to disable super admin. Code: ${err.code}, message: ${err.message}`); 340 return; 341 } 342 console.info('Succeeded in disabling super admin'); 343}); 344``` 345 346## adminManager.disableSuperAdmin 347 348disableSuperAdmin(bundleName: String): Promise\<void> 349 350Disables a super administrator application for the administrator based on **bundleName**. This API uses a promise to return the result. 351 352**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 353 354**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 355 356 357 358**Model restriction**: This API can be used only in the stage model. 359 360**Parameters** 361 362| Name | Type | Mandatory | Description | 363| ---------- | ------ | ---- | ------------ | 364| bundleName | String | Yes | Bundle name of the super administrator application to disable.| 365 366**Return value** 367 368| Type | Description | 369| ----------------- | ----------------- | 370| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 371 372**Error codes** 373 374For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 375 376| ID| Error Message | 377| ------- | ----------------------------------------------------------------- | 378| 9200005 | Failed to deactivate the administrator application of the device. | 379| 201 | Permission verification failed. The application does not have the permission required to call the API. | 380| 202 | Permission verification failed. A non-system application calls a system API. | 381| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 382 383**Example** 384 385```ts 386import { Want } from '@kit.AbilityKit'; 387import { BusinessError } from '@kit.BasicServicesKit'; 388let bundleName: string = 'com.example.myapplication'; 389 390adminManager.disableSuperAdmin(bundleName).catch((err: BusinessError) => { 391 console.error(`Failed to disable super admin. Code: ${err.code}, message: ${err.message}`); 392}); 393``` 394 395## adminManager.isAdminEnabled 396 397isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void 398 399Checks whether a device administrator application of the current user is enabled. This API uses an asynchronous callback to return the result. 400 401**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 402 403 404 405**Model restriction**: This API can be used only in the stage model. 406 407**Parameters** 408 409| Name | Type | Mandatory | Description | 410| -------- | ----------------------------------- | ---- | -------------------- | 411| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application to check. | 412| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is a Boolean value (**true** means that the device administrator application is enabled; and **false** means the opposite). If the operation fails, **err** is an error object.| 413 414**Error codes** 415 416For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 417 418| ID| Error Message | 419| -------- | ------------------------------------------------------------ | 420| 202 | Permission verification failed. A non-system application calls a system API. | 421| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 422 423**Example** 424 425```ts 426import { Want } from '@kit.AbilityKit'; 427let wantTemp: Want = { 428 bundleName: 'bundleName', 429 abilityName: 'abilityName', 430}; 431 432adminManager.isAdminEnabled(wantTemp, (err, result) => { 433 if (err) { 434 console.error(`Failed to query admin is enabled or not. Code: ${err.code}, message: ${err.message}`); 435 return; 436 } 437 console.info(`Succeeded in querying admin is enabled or not, result : ${result}`); 438}); 439``` 440 441## adminManager.isAdminEnabled 442 443isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void 444 445Checks whether a device administrator application of the specified user is enabled. This API uses an asynchronous callback to return the result. 446 447**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 448 449 450 451**Model restriction**: This API can be used only in the stage model. 452 453**Parameters** 454 455| Name | Type | Mandatory | Description | 456| -------- | ----------------------------------- | ---- | ---------------------------- | 457| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application to check. | 458| userId | number | Yes | User ID, which must be greater than or equal to 0.<br>The default value is the user ID of the caller. | 459| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is a Boolean value (**true** means that the device administrator application is enabled; and **false** means the opposite). If the operation fails, **err** is an error object. | 460 461**Error codes** 462 463For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 464 465| ID| Error Message | 466| -------- | ------------------------------------------------------------ | 467| 202 | Permission verification failed. A non-system application calls a system API. | 468| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 469 470**Example** 471 472```ts 473import { Want } from '@kit.AbilityKit'; 474let wantTemp: Want = { 475 bundleName: 'bundleName', 476 abilityName: 'abilityName', 477}; 478 479adminManager.isAdminEnabled(wantTemp, 100, (err, result) => { 480 if (err) { 481 console.error(`Failed to query admin is enabled. Code: ${err.code}, message: ${err.message}`); 482 return; 483 } 484 console.info(`Succeeded in querying admin is enabled or not, result : ${result}`); 485}); 486``` 487 488## adminManager.isAdminEnabled 489 490isAdminEnabled(admin: Want, userId?: number): Promise\<boolean> 491 492Checks whether a device administrator application of the current or specified user is enabled. This API uses a promise to return the result. 493 494**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 495 496 497 498**Model restriction**: This API can be used only in the stage model. 499 500**Parameters** 501 502| Name | Type | Mandatory | Description | 503| ------ | ----------------------------------- | ---- | ---------------------------- | 504| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application to check. | 505| userId | number | No | User ID, which must be greater than or equal to 0.<br>- If **userId** is passed in, this API applies to the specified user.<br>- If **userId** is not passed in, this API applies to the current user.| 506 507**Return value** 508 509| Type | Description | 510| ----------------- | ------------------- | 511| Promise\<boolean> | Promise used to return the result. The value **true** means the device administrator application is enabled; the value **false** means the opposite.| 512 513**Error codes** 514 515For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 516 517| ID| Error Message | 518| -------- | ------------------------------------------------------------ | 519| 202 | Permission verification failed. A non-system application calls a system API. | 520| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 521 522**Example** 523 524```ts 525import { Want } from '@kit.AbilityKit'; 526import { BusinessError } from '@kit.BasicServicesKit'; 527let wantTemp: Want = { 528 bundleName: 'bundleName', 529 abilityName: 'abilityName', 530}; 531 532adminManager.isAdminEnabled(wantTemp, 100).then((result) => { 533 console.info(`Succeeded in querying admin is enabled or not, result : ${result}`); 534}).catch((err: BusinessError) => { 535 console.error(`Failed to query admin is enabled or not. Code: ${err.code}, message: ${err.message}`); 536}); 537``` 538 539## adminManager.isSuperAdmin 540 541isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void 542 543Checks whether a super administrator application of the administrator is enabled based on **bundleName**. This API uses an asynchronous callback to return the result. 544 545**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 546 547 548 549**Model restriction**: This API can be used only in the stage model. 550 551**Parameters** 552 553| Name | Type | Mandatory | Description | 554| ---------- | ----------------------- | ---- | -------------------- | 555| bundleName | String | Yes | Super administrator application to check. | 556| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is a Boolean value (**true** means that the device administrator application is enabled; and **false** means the opposite). If the operation fails, **err** is an error object.| 557 558**Error codes** 559 560For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 561 562| ID| Error Message | 563| -------- | ------------------------------------------------------------ | 564| 202 | Permission verification failed. A non-system application calls a system API. | 565| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 566 567**Example** 568 569```ts 570import { Want } from '@kit.AbilityKit'; 571let bundleName: string = 'com.example.myapplication'; 572 573adminManager.isSuperAdmin(bundleName, (err, result) => { 574 if (err) { 575 console.error(`Failed to query admin is super admin or not. Code: ${err.code}, message: ${err.message}`); 576 return; 577 } 578 console.info(`Succeeded in querying admin is super admin or not, result : ${result}`); 579}); 580``` 581 582## adminManager.isSuperAdmin 583 584isSuperAdmin(bundleName: String): Promise\<boolean> 585 586Checks whether a super administrator application of the administrator is enabled based on **bundleName**. This API uses a promise to return the result. 587 588**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 589 590 591 592**Model restriction**: This API can be used only in the stage model. 593 594**Parameters** 595 596| Name | Type | Mandatory | Description | 597| ---------- | ------ | ---- | --------- | 598| bundleName | String | Yes | Super administrator application to check.| 599 600**Return value** 601 602| ID | Error Message | 603| ----------------- | ------------------- | 604| Promise\<boolean> | Promise used to return the result. The value **true** means the super administrator application is enabled; the value **false** means the opposite. | 605 606**Error codes** 607 608For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 609 610| ID| Error Message | 611| -------- | ------------------------------------------------------------ | 612| 202 | Permission verification failed. A non-system application calls a system API. | 613| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 614 615**Example** 616 617```ts 618import { Want } from '@kit.AbilityKit'; 619import { BusinessError } from '@kit.BasicServicesKit'; 620let bundleName: string = 'com.example.myapplication'; 621 622adminManager.isSuperAdmin(bundleName).then((result) => { 623 console.info(`Succeeded in querying admin is super admin or not, result : ${result}`); 624}).catch((err: BusinessError) => { 625 console.error(`Failed to query admin is super admin or not. Code: ${err.code}, message: ${err.message}`); 626}); 627``` 628 629## adminManager.getSuperAdmin<sup>12+</sup> 630 631getSuperAdmin(): Promise\<Want> 632 633Obtains the super device administrator application of this administrator. This API uses a promise to return the result. 634 635**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 636 637 638 639**Model restriction**: This API can be used only in the stage model. 640 641**Return value** 642 643| Type | Description | 644| ------------------------------------------------------------ | ------------------------------------------------------------ | 645| Promise\<[Want](../apis-ability-kit/js-apis-app-ability-want.md)> | Promise used to return the super device administrator application obtained. If no super device administrator application is activated on the device, **bundleName** and **abilityName** in **Want** returned are empty strings.| 646 647**Error codes** 648 649For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 650 651| ID| Error Message | 652| -------- | ------------------------------------------------------------ | 653| 202 | Permission verification failed. A non-system application calls a system API. | 654 655**Example** 656 657```ts 658import { BusinessError } from '@kit.BasicServicesKit'; 659 660adminManager.getSuperAdmin().then((result) => { 661 console.info(`Succeeded in getting super admin :${JSON.stringify(result)}`); 662}).catch((err: BusinessError) => { 663 console.error(`Failed to get super admin. Code: ${err.code}, message: ${err.message}`); 664}) 665``` 666 667## adminManager.setEnterpriseInfo 668 669setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback\<void>): void 670 671Sets enterprise information for a device administrator application. This API uses an asynchronous callback to return the result. 672 673**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO 674 675**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 676 677 678 679**Model restriction**: This API can be used only in the stage model. 680 681**Parameters** 682 683| Name | Type | Mandatory | Description | 684| -------------- | ----------------------------------- | ---- | ---------------------- | 685| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 686| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information to set. | 687| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 688 689**Error codes** 690 691For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 692 693| ID| Error Message | 694| ------- | ----------------------------------------------------- | 695| 9200001 | The application is not an administrator application of the device. | 696| 201 | Permission verification failed. The application does not have the permission required to call the API. | 697| 202 | Permission verification failed. A non-system application calls a system API. | 698| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 699 700**Example** 701 702```ts 703import { Want } from '@kit.AbilityKit'; 704let wantTemp: Want = { 705 bundleName: 'com.example.myapplication', 706 abilityName: 'EntryAbility', 707}; 708let enterpriseInfo: adminManager.EnterpriseInfo = { 709 name: 'enterprise name', 710 description: 'enterprise description' 711} 712 713adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo, (err) => { 714 if (err) { 715 console.error(`Failed to set enterprise info. Code: ${err.code}, message: ${err.message}`); 716 return; 717 } 718 console.info('Succeeded in setting enterprise info'); 719}); 720``` 721 722## adminManager.setEnterpriseInfo 723 724setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void> 725 726Sets enterprise information for a device administrator application. This API uses a promise to return the result. 727 728**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO 729 730**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 731 732 733 734**Model restriction**: This API can be used only in the stage model. 735 736**Parameters** 737 738| Name | Type | Mandatory | Description | 739| -------------- | ----------------------------------- | ---- | ------------ | 740| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 741| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | Yes | Enterprise information to set.| 742 743**Return value** 744 745| Type | Description | 746| ----------------- | --------------------- | 747| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 748 749**Error codes** 750 751For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 752 753| ID| Error Message | 754| ------- | ----------------------------------------------------- | 755| 9200001 | The application is not an administrator application of the device. | 756| 201 | Permission verification failed. The application does not have the permission required to call the API. | 757| 202 | Permission verification failed. A non-system application calls a system API. | 758| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 759 760**Example** 761 762```ts 763import { Want } from '@kit.AbilityKit'; 764import { BusinessError } from '@kit.BasicServicesKit'; 765let wantTemp: Want = { 766 bundleName: 'com.example.myapplication', 767 abilityName: 'EntryAbility', 768}; 769let enterpriseInfo: adminManager.EnterpriseInfo = { 770 name: 'enterprise name', 771 description: 'enterprise description' 772} 773 774adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch((err: BusinessError) => { 775 console.error(`Failed to set enterprise info. Code: ${err.code}, message: ${err.message}`); 776}); 777``` 778 779## adminManager.getEnterpriseInfo 780 781getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): void 782 783Obtains the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result. 784 785**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 786 787 788 789**Model restriction**: This API can be used only in the stage model. 790 791**Parameters** 792 793| Name | Type | Mandatory | Description | 794| -------- | ---------------------------------------- | ---- | ------------------------ | 795| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 796| callback | AsyncCallback<[EnterpriseInfo](#enterpriseinfo)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the enterprise information of the device administrator application obtained. If the operation fails, **err** is an error object.| 797 798**Error codes** 799 800For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 801 802| ID| Error Message | 803| ------- | ----------------------------------------------------- | 804| 9200001 | The application is not an administrator application of the device. | 805| 202 | Permission verification failed. A non-system application calls a system API. | 806| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 807 808**Example** 809 810```ts 811import { Want } from '@kit.AbilityKit'; 812let wantTemp: Want = { 813 bundleName: 'com.example.myapplication', 814 abilityName: 'EntryAbility', 815}; 816 817adminManager.getEnterpriseInfo(wantTemp, (err, result) => { 818 if (err) { 819 console.error(`Failed to get enterprise info. Code: ${err.code}, message: ${err.message}`); 820 return; 821 } 822 console.info(`Succeeded in getting enterprise info, enterprise name : ${result.name}, enterprise description : ${result.description}`); 823}); 824``` 825 826## adminManager.getEnterpriseInfo 827 828getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> 829 830Obtains the enterprise information of a device administrator application. This API uses a promise to return the result. 831 832**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 833 834 835 836**Model restriction**: This API can be used only in the stage model. 837 838**Parameters** 839 840| Name | Type | Mandatory | Description | 841| ----- | ----------------------------------- | ---- | ------- | 842| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 843 844**Return value** 845 846| Type | Description | 847| ---------------------------------------- | ------------------------- | 848| Promise<[EnterpriseInfo](#enterpriseinfo)> | Promise used to return the enterprise information obtained.| 849 850**Error codes** 851 852For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 853 854| ID| Error Message | 855| ------- | ----------------------------------------------------- | 856| 9200001 | The application is not an administrator application of the device. | 857| 202 | Permission verification failed. A non-system application calls a system API. | 858| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 859 860**Example** 861 862```ts 863import { Want } from '@kit.AbilityKit'; 864import { BusinessError } from '@kit.BasicServicesKit'; 865let wantTemp: Want = { 866 bundleName: 'com.example.myapplication', 867 abilityName: 'EntryAbility', 868}; 869 870adminManager.getEnterpriseInfo(wantTemp).then((result) => { 871 console.info(`Succeeded in getting enterprise info, enterprise name : ${result.name}, enterprise description : ${result.description}`); 872}).catch((err: BusinessError) => { 873 console.error(`Failed to get enterprise info. Code: ${err.code}, message: ${err.message}`); 874}); 875``` 876 877## adminManager.subscribeManagedEvent 878 879subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void 880 881Subscribes to system management events of a device administrator application. This API uses an asynchronous callback to return the result. 882 883**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 884 885**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 886 887 888 889**Model restriction**: This API can be used only in the stage model. 890 891**Parameters** 892 893| Name | Type | Mandatory | Description | 894| ----- | ----------------------------------- | ---- | ------- | 895| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 896| managedEvents | Array\<[ManagedEvent](js-apis-enterprise-adminManager.md#managedevent)> | Yes| Array of events to subscribe to.| 897| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 898 899**Error codes** 900 901For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 902 903| ID| Error Message | 904| -------- | ------------------------------------------------------------ | 905| 9200001 | The application is not an administrator application of the device. | 906| 9200008 | The specified system event is invalid. | 907| 201 | Permission verification failed. The application does not have the permission required to call the API. | 908| 202 | Permission verification failed. A non-system application calls a system API. | 909| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 910 911**Example** 912 913```ts 914import { Want } from '@kit.AbilityKit'; 915let wantTemp: Want = { 916 bundleName: 'bundleName', 917 abilityName: 'abilityName', 918}; 919let events: Array<adminManager.ManagedEvent> = [adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_ADDED, adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_REMOVED]; 920 921adminManager.subscribeManagedEvent(wantTemp, events, (err) => { 922 if (err) { 923 console.error(`Failed to subscribe managed event. Code: ${err.code}, message: ${err.message}`); 924 return; 925 } 926 console.info('Succeeded in subscribe managed event'); 927}); 928``` 929 930## adminManager.subscribeManagedEvent 931 932subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void> 933 934Subscribes to system management events of a device administrator application. This API uses a promise to return the result. 935 936**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 937 938**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 939 940 941 942**Model restriction**: This API can be used only in the stage model. 943 944**Parameters** 945 946| Name | Type | Mandatory | Description | 947| ----- | ----------------------------------- | ---- | ------- | 948| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 949| managedEvents | Array\<[ManagedEvent](js-apis-enterprise-adminManager.md#managedevent)> | Yes| Array of events to subscribe to.| 950 951**Return value** 952 953| Type | Description | 954| ----- | ----------------------------------- | 955| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 956 957**Error codes** 958 959For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 960 961| ID| Error Message | 962| ------- | ----------------------------------------------------- | 963| 9200001 | The application is not an administrator application of the device. | 964| 9200008 | The specified system event is invalid. | 965| 201 | Permission verification failed. The application does not have the permission required to call the API. | 966| 202 | Permission verification failed. A non-system application calls a system API. | 967| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 968 969**Example** 970 971```ts 972import { Want } from '@kit.AbilityKit'; 973import { BusinessError } from '@kit.BasicServicesKit'; 974let wantTemp: Want = { 975 bundleName: 'bundleName', 976 abilityName: 'abilityName', 977}; 978let events: Array<adminManager.ManagedEvent> = [adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_ADDED, adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_REMOVED]; 979 980adminManager.subscribeManagedEvent(wantTemp, events).then(() => { 981}).catch((err: BusinessError) => { 982 console.error(`Failed to subscribe managed event. Code: ${err.code}, message: ${err.message}`); 983}) 984``` 985 986## adminManager.unsubscribeManagedEvent 987 988unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void 989 990Unsubscribes from system management events of a device administrator application. This API uses an asynchronous callback to return the result. 991 992**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 993 994**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 995 996 997 998**Model restriction**: This API can be used only in the stage model. 999 1000**Parameters** 1001 1002| Name | Type | Mandatory | Description | 1003| ----- | ----------------------------------- | ---- | ------- | 1004| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 1005| managedEvents | Array\<[ManagedEvent](js-apis-enterprise-adminManager.md#managedevent)> | Yes| Array of events to unsubscribe from.| 1006| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 1007 1008**Error codes** 1009 1010For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1011 1012| ID| Error Message | 1013| ------- | ----------------------------------------------------- | 1014| 9200001 | The application is not an administrator application of the device. | 1015| 9200008 | The specified system event is invalid. | 1016| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1017| 202 | Permission verification failed. A non-system application calls a system API. | 1018| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1019 1020**Example** 1021 1022```ts 1023import { Want } from '@kit.AbilityKit'; 1024let wantTemp: Want = { 1025 bundleName: 'bundleName', 1026 abilityName: 'abilityName', 1027}; 1028let events: Array<adminManager.ManagedEvent> = [adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_ADDED, adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_REMOVED]; 1029 1030adminManager.unsubscribeManagedEvent(wantTemp, events, (err) => { 1031 if (err) { 1032 console.error(`Failed to unsubscribe managed event. Code: ${err.code}, message: ${err.message}`); 1033 return; 1034 } 1035 console.info('Succeeded in unsubscribe managed event'); 1036}); 1037``` 1038 1039## adminManager.unsubscribeManagedEvent 1040 1041unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void> 1042 1043Unsubscribes from system management events of a device administrator application. This API uses a promise to return the result. 1044 1045**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT 1046 1047**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1048 1049 1050 1051**Model restriction**: This API can be used only in the stage model. 1052 1053**Parameters** 1054 1055| Name | Type | Mandatory | Description | 1056| ----- | ----------------------------------- | ---- | ------- | 1057| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 1058| managedEvents | Array\<[ManagedEvent](js-apis-enterprise-adminManager.md#managedevent)> | Yes| Array of events to unsubscribe from.| 1059 1060**Return value** 1061 1062| Type | Description | 1063| ----- | ----------------------------------- | 1064| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 1065 1066**Error codes** 1067 1068For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1069 1070| ID| Error Message | 1071| ------- | ----------------------------------------------------- | 1072| 9200001 | The application is not an administrator application of the device. | 1073| 9200008 | The specified system event is invalid. | 1074| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1075| 202 | Permission verification failed. A non-system application calls a system API. | 1076| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1077 1078**Example** 1079 1080```ts 1081import { Want } from '@kit.AbilityKit'; 1082import { BusinessError } from '@kit.BasicServicesKit'; 1083let wantTemp: Want = { 1084 bundleName: 'bundleName', 1085 abilityName: 'abilityName', 1086}; 1087let events: Array<adminManager.ManagedEvent> = [adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_ADDED, adminManager.ManagedEvent.MANAGED_EVENT_BUNDLE_REMOVED]; 1088 1089adminManager.unsubscribeManagedEvent(wantTemp, events).then(() => { 1090}).catch((err: BusinessError) => { 1091 console.error(`Failed to unsubscribe managed event. Code: ${err.code}, message: ${err.message}`); 1092}) 1093``` 1094 1095## adminManager.authorizeAdmin<sup>10+</sup> 1096 1097authorizeAdmin(admin: Want, bundleName: string, callback: AsyncCallback<void>): void 1098 1099Authorizes the administrator rights to an application through the specified device administrator application. This API uses an asynchronous callback to return the result. 1100 1101**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 1102 1103**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1104 1105 1106 1107**Model restriction**: This API can be used only in the stage model. 1108 1109**Parameters** 1110 1111| Name | Type | Mandatory | Description | 1112| ----- | ----------------------------------- | ---- | ------- | 1113| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 1114| bundleName | string | Yes| Bundle name of the application to be authorized with the administrator rights.| 1115| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 1116 1117**Error codes** 1118 1119For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1120 1121| ID| Error Message | 1122| ------- | ----------------------------------------------------- | 1123| 9200001 | The application is not an administrator application of the device. | 1124| 9200002 | The administrator application does not have permission to manage the device. | 1125| 9200009 | Failed to grant the permission to the application. | 1126| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1127| 202 | Permission verification failed. A non-system application calls a system API. | 1128| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1129 1130**Example** 1131 1132```ts 1133import { Want } from '@kit.AbilityKit'; 1134let wantTemp: Want = { 1135 bundleName: 'bundleName', 1136 abilityName: 'abilityName', 1137}; 1138let bundleName: string = "com.example.application"; 1139 1140adminManager.authorizeAdmin(wantTemp, bundleName, (err) => { 1141 if (err) { 1142 console.error(`Failed to authorize permission to the application. Code: ${err.code}, message: ${err.message}`); 1143 return; 1144 } 1145 console.info('Successfully authorized permission to the application'); 1146}); 1147``` 1148 1149## adminManager.authorizeAdmin<sup>10+</sup> 1150 1151authorizeAdmin(admin: Want, bundleName: string): Promise<void> 1152 1153Authorizes the administrator rights to an application through the specified device administrator application. This API uses a promise to return the result. 1154 1155**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN 1156 1157**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1158 1159 1160 1161**Model restriction**: This API can be used only in the stage model. 1162 1163**Parameters** 1164 1165| Name | Type | Mandatory | Description | 1166| ----- | ----------------------------------- | ---- | ------- | 1167| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 1168| bundleName | string | Yes| Bundle name of the application to be authorized with the administrator rights.| 1169 1170**Return value** 1171 1172| Type | Description | 1173| ----- | ----------------------------------- | 1174| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 1175 1176**Error codes** 1177 1178For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1179 1180| ID| Error Message | 1181| ------- | ----------------------------------------------------- | 1182| 9200001 | The application is not an administrator application of the device. | 1183| 9200002 | The administrator application does not have permission to manage the device. | 1184| 9200009 | Failed to grant the permission to the application. | 1185| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1186| 202 | Permission verification failed. A non-system application calls a system API. | 1187| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1188 1189**Example** 1190 1191```ts 1192import { Want } from '@kit.AbilityKit'; 1193import { BusinessError } from '@kit.BasicServicesKit'; 1194let wantTemp: Want = { 1195 bundleName: 'bundleName', 1196 abilityName: 'abilityName', 1197}; 1198let bundleName: string = "com.example.application"; 1199 1200adminManager.authorizeAdmin(wantTemp, bundleName).then(() => { 1201}).catch((err: BusinessError) => { 1202 console.error(`Failed to authorize permission to the application. Code: ${err.code}, message: ${err.message}`); 1203}) 1204``` 1205 1206## EnterpriseInfo 1207 1208Represents the enterprise information of a device administrator application. 1209 1210**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1211 1212 1213 1214| Name | Type | Mandatory| Description | 1215| ----------- | --------| ---- | ------------------------------- | 1216| name | string | Yes | Name of the enterprise.| 1217| description | string | Yes | Description of the enterprise.| 1218 1219## AdminType 1220 1221Enumerates the types of device administrator applications. 1222 1223**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1224 1225 1226 1227| Name | Value | Description | 1228| ----------------- | ---- | ----- | 1229| ADMIN_TYPE_NORMAL | 0x00 | Common administrator application.| 1230| ADMIN_TYPE_SUPER | 0x01 | Super administrator application.| 1231