1# @ohos.enterprise.wifiManager (Wi-Fi Management) 2 3The **wifiManager** module provides Wi-Fi management capabilities for enterprise devices, including obtaining the Wi-Fi status. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> - The APIs of this module can be used only in the stage model. 10> 11> - The APIs of this module can be called only by a device administrator application that is enabled. For details, see [MDM Kit Development](../../mdm/mdm-kit-guide.md). 12> 13> - The global restriction policies are provided by **restrictions**. To disable Wi-Fi globally, see [@ohos.enterprise.restrictions](js-apis-enterprise-restrictions.md). 14 15## Modules to Import 16 17```ts 18import { wifiManager } from '@kit.MDMKit'; 19``` 20 21## wifiManager.isWifiActiveSync 22 23isWifiActiveSync(admin: Want): boolean 24 25Queries the Wi-Fi status of the current device. 26 27**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 28 29**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 30 31 32 33**Parameters** 34 35| Name| Type | Mandatory| Description | 36| ------ | ------------------------------------------------------- | ---- | ---------------------- | 37| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 38 39**Return value** 40 41| Type | Description | 42| ------- | ---------------------------------------------------------- | 43| boolean | Returns the Wi-Fi status. The value **true** means Wi-Fi is enabled, and the value **false** means the opposite.| 44 45**Error codes** 46 47For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 48 49| ID| Error Message | 50| -------- | ------------------------------------------------------------ | 51| 9200001 | The application is not an administrator application of the device. | 52| 9200002 | The administrator application does not have permission to manage the device. | 53| 201 | Permission verification failed. The application does not have the permission required to call the API. | 54| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 55 56**Example** 57 58```ts 59import { Want } from '@kit.AbilityKit'; 60let wantTemp: Want = { 61 bundleName: 'com.example.myapplication', 62 abilityName: 'EntryAbility', 63}; 64 65try { 66 let result: boolean = wifiManager.isWifiActiveSync(wantTemp); 67 console.info(`Succeeded in query is wifi active or not, result : ${result}`); 68} catch (err) { 69 console.error(`Failed to query is wifi active or not. Code: ${err.code}, message: ${err.message}`); 70} 71``` 72 73## wifiManager.setWifiProfileSync 74 75setWifiProfileSync(admin: Want, profile: WifiProfile): void 76 77Configures Wi-Fi for the current device to connect to a specified network. 78 79**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 80 81**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 82 83 84 85**Parameters** 86 87| Name | Type | Mandatory| Description | 88| ------- | ------------------------------------------------------- | ---- | ---------------------- | 89| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 90| profile | [WifiProfile](#wifiprofile) | Yes | Wi-Fi configuration information. | 91 92**Error codes** 93 94For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 95 96| ID| Error Message | 97| -------- | ------------------------------------------------------------ | 98| 9200001 | The application is not an administrator application of the device. | 99| 9200002 | The administrator application does not have permission to manage the device. | 100| 201 | Permission verification failed. The application does not have the permission required to call the API. | 101| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 102 103**Example** 104 105```ts 106import { Want } from '@kit.AbilityKit'; 107import { BusinessError } from '@kit.BasicServicesKit'; 108 109let wantTemp: Want = { 110 bundleName: 'com.example.myapplication', 111 abilityName: 'EntryAbility', 112}; 113let profile: wifiManager.WifiProfile = { 114 'ssid': 'name', 115 'preSharedKey': 'passwd', 116 'securityType': wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK 117}; 118 119try { 120 wifiManager.setWifiProfileSync(wantTemp, profile); 121 console.info('Succeeded in setting wifi profile.'); 122} catch (err) { 123 console.error(`Failed to set wifi profile. Code: ${err.code}, message: ${err.message}`); 124} 125``` 126 127## wifiManager.addAllowedWifiList<sup>19+</sup> 128 129addAllowedWifiList(admin: Want, list: Array<WifiAccessInfo>): void 130 131Adds allowed Wi-Fi networks. The current device can only connect to the allowed Wi-Fi networks. 132 133A policy conflict is reported when this API is called in the following scenarios: 134 1351. Wi-Fi networks have been disabled by calling [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy). You can resolve the conflict by enabling the Wi-Fi networks through [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy). 1362. Disallowed Wi-Fi networks have been added by calling [addDisallowedWifiList](#wifimanageradddisallowedwifilist19). You can resolve the conflict by removing the disallowed Wi-Fi networks through [removeDisallowedWifiList](#wifimanagerremovedisallowedwifilist19). 137 138**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 139 140**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 141 142 143 144**Parameters** 145 146| Name | Type | Mandatory| Description | 147| ------------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 148| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 149| list | Array<[WifiAccessInfo](#wifiaccessinfo19)> | Yes | A list of allowed Wi-Fi networks. The maximum length of the array is 200. For example, if there are already 100 Wi-Fi networks, a maximum of 100 more can be added.| 150 151**Error codes** 152 153For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 154 155| ID| Error Message | 156| -------- | ------------------------------------------------------------ | 157| 9200001 | The application is not an administrator application of the device. | 158| 9200002 | The administrator application does not have permission to manage the device. | 159| 9200010 | A conflict policy has been configured. | 160| 201 | Permission verification failed. The application does not have the permission required to call the API. | 161 162**Example** 163 164```ts 165import { Want } from '@kit.AbilityKit'; 166 167let wantTemp: Want = { 168 // Replace it as required. 169 bundleName: 'com.example.edmtest', 170 abilityName: 'com.example.edmtest.EnterpriseAdminAbility' 171}; 172try { 173 let wifiIds: Array<wifiManager.WifiAccessInfo> = [{ 174 // Replace it as required. 175 ssid: "wifi_name", 176 bssid: "68:77:24:77:A6:D8" 177 }]; 178 wifiManager.addAllowedWifiList(wantTemp, wifiIds); 179 console.info(`Succeeded in adding allowed wifi list.`); 180} catch (err) { 181 console.error(`Failed to add allowed wifi list. Code: ${err.code}, message: ${err.message}`); 182} 183``` 184 185## wifiManager.removeAllowedWifiList<sup>19+</sup> 186 187removeAllowedWifiList(admin: Want, list: Array<WifiAccessInfo>): void 188 189Removes allowed Wi-Fi networks. If some Wi-Fi networks are removed from the allowed list, the current device can only connect to the remaining ones; if all Wi-Fi networks are removed from the allowed list, the current device can connect to any Wi-Fi network. 190 191**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 192 193**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 194 195 196 197**Parameters** 198 199| Name | Type | Mandatory| Description | 200| ------------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 201| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 202| list | Array<[WifiAccessInfo](#wifiaccessinfo19)> | Yes | List of allowed Wi-Fi networks to remove. The maximum length of the array is 200. | 203 204**Error codes** 205 206For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 207 208| ID| Error Message | 209| -------- | ------------------------------------------------------------ | 210| 9200001 | The application is not an administrator application of the device. | 211| 9200002 | The administrator application does not have permission to manage the device. | 212| 201 | Permission verification failed. The application does not have the permission required to call the API. | 213 214**Example** 215 216```ts 217import { Want } from '@kit.AbilityKit'; 218 219let wantTemp: Want = { 220 // Replace it as required. 221 bundleName: 'com.example.edmtest', 222 abilityName: 'com.example.edmtest.EnterpriseAdminAbility' 223}; 224try { 225 let wifiIds: Array<wifiManager.WifiAccessInfo> = [{ 226 // Replace it as required. 227 ssid: "wifi_name", 228 bssid: "68:77:24:77:A6:D8" 229 }]; 230 wifiManager.removeAllowedWifiList(wantTemp, wifiIds); 231 console.info(`Succeeded in removing allowed wifi list.`); 232} catch (err) { 233 console.error(`Failed to remove allowed wifi list. Code: ${err.code}, message: ${err.message}`); 234} 235``` 236 237## wifiManager.getAllowedWifiList<sup>19+</sup> 238 239getAllowedWifiList(admin: Want): Array<WifiAccessInfo> 240 241Obtains the allowed Wi-Fi networks. 242 243**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 244 245**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 246 247 248 249**Parameters** 250 251| Name| Type | Mandatory| Description | 252| ------ | ------------------------------------------------------- | ---- | -------------------------------------- | 253| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 254 255**Return value** 256 257| Type | Description | 258| ---------------------------------- | ------------------------- | 259| Array<[WifiAccessInfo](#wifiaccessinfo19)> | Allowed Wi-Fi networks.| 260 261**Error codes** 262 263For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 264 265| ID| Error Message | 266| -------- | ------------------------------------------------------------ | 267| 9200001 | The application is not an administrator application of the device. | 268| 9200002 | The administrator application does not have permission to manage the device. | 269| 201 | Permission verification failed. The application does not have the permission required to call the API. | 270 271**Example** 272 273```ts 274import { Want } from '@kit.AbilityKit'; 275 276let wantTemp: Want = { 277 // Replace it as required. 278 bundleName: 'com.example.edmtest', 279 abilityName: 'com.example.edmtest.EnterpriseAdminAbility' 280}; 281try { 282 let result: Array<wifiManager.WifiAccessInfo> = wifiManager.getAllowedWifiList(wantTemp); 283 console.info(`Succeeded in getting allowed wifi list. Result: ${JSON.stringify(result)}`); 284} catch (err) { 285 console.error(`Failed to get allowed wifi list. Code: ${err.code}, message: ${err.message}`); 286} 287``` 288 289## wifiManager.addDisallowedWifiList<sup>19+</sup> 290 291addDisallowedWifiList(admin: Want, list: Array<WifiAccessInfo>): void 292 293Adds disallowed Wi-Fi networks. The current device cannot connect to the disallowed Wi-Fi networks. 294 295A policy conflict is reported when this API is called in the following scenarios: 296 2971. Wi-Fi networks have been disabled by calling [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy). You can resolve the conflict by enabling the Wi-Fi networks through [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy). 2982. Allowed Wi-Fi networks have been added by calling [addAllowedWifiList](#wifimanageraddallowedwifilist19). You can resolve the conflict by removing the allowed Wi-Fi networks through [removeAllowedWifiList](#wifimanagerremoveallowedwifilist19). 299 300**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 301 302**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 303 304 305 306**Parameters** 307 308| Name | Type | Mandatory| Description | 309| ------------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 310| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 311| list | Array<[WifiAccessInfo](#wifiaccessinfo19)> | Yes | A list of disallowed Wi-Fi networks. The maximum length of the array is 200. For example, if there are already 100 Wi-Fi networks, a maximum of 100 more can be added.| 312 313**Error codes** 314 315For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 316 317| ID| Error Message | 318| -------- | ------------------------------------------------------------ | 319| 9200001 | The application is not an administrator application of the device. | 320| 9200002 | The administrator application does not have permission to manage the device. | 321| 9200010 | A conflict policy has been configured. | 322| 201 | Permission verification failed. The application does not have the permission required to call the API. | 323 324**Example** 325 326```ts 327import { Want } from '@kit.AbilityKit'; 328 329let wantTemp: Want = { 330 // Replace it as required. 331 bundleName: 'com.example.edmtest', 332 abilityName: 'com.example.edmtest.EnterpriseAdminAbility' 333}; 334try { 335 let wifiIds: Array<wifiManager.WifiAccessInfo> = [{ 336 // Replace it as required. 337 ssid: "wifi_name", 338 bssid: "68:77:24:77:A6:D8" 339 }]; 340 wifiManager.addDisallowedWifiList(wantTemp, wifiIds); 341 console.info(`Succeeded in adding disallowed wifi list.`); 342} catch (err) { 343 console.error(`Failed to add disallowed wifi list. Code: ${err.code}, message: ${err.message}`); 344} 345``` 346 347## wifiManager.removeDisallowedWifiList<sup>19+</sup> 348 349removeDisallowedWifiList(admin: Want, list: Array<WifiAccessInfo>): void 350 351Removes disallowed Wi-Fi networks. If some Wi-Fi networks are removed from the disallowed list, the current device cannot connect to the remaining ones; if all Wi-Fi networks are removed from the disallowed list, the current device can connect to any Wi-Fi network. 352 353**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 354 355**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 356 357 358 359**Parameters** 360 361| Name | Type | Mandatory| Description | 362| ------------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 363| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 364| list | Array<[WifiAccessInfo](#wifiaccessinfo19)> | Yes | List of disallowed Wi-Fi networks to remove. The maximum length of the array is 200. | 365 366**Error codes** 367 368For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 369 370| ID| Error Message | 371| -------- | ------------------------------------------------------------ | 372| 9200001 | The application is not an administrator application of the device. | 373| 9200002 | The administrator application does not have permission to manage the device. | 374| 201 | Permission verification failed. The application does not have the permission required to call the API. | 375 376**Example** 377 378```ts 379import { Want } from '@kit.AbilityKit'; 380 381let wantTemp: Want = { 382 // Replace it as required. 383 bundleName: 'com.example.edmtest', 384 abilityName: 'com.example.edmtest.EnterpriseAdminAbility' 385}; 386try { 387 let wifiIds: Array<wifiManager.WifiAccessInfo> = [{ 388 // Replace it as required. 389 ssid: "wifi_name", 390 bssid: "68:77:24:77:A6:D8" 391 }]; 392 wifiManager.removeDisallowedWifiList(wantTemp, wifiIds); 393 console.info(`Succeeded in removing disallowed wifi list.`); 394} catch (err) { 395 console.error(`Failed to remove disallowed wifi list. Code: ${err.code}, message: ${err.message}`); 396} 397``` 398 399## wifiManager.getDisallowedWifiList<sup>19+</sup> 400 401getDisallowedWifiList(admin: Want): Array<WifiAccessInfo> 402 403Obtains disallowed Wi-Fi networks. 404 405**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 406 407**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 408 409 410 411**Parameters** 412 413| Name| Type | Mandatory| Description | 414| ------ | ------------------------------------------------------- | ---- | -------------------------------------- | 415| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 416 417**Return value** 418 419| Type | Description | 420| ---------------------------------- | ------------------------- | 421| Array<[WifiAccessInfo](#wifiaccessinfo19)> | Disallowed Wi-Fi networks.| 422 423**Error codes** 424 425For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 426 427| ID| Error Message | 428| -------- | ------------------------------------------------------------ | 429| 9200001 | The application is not an administrator application of the device. | 430| 9200002 | The administrator application does not have permission to manage the device. | 431| 201 | Permission verification failed. The application does not have the permission required to call the API. | 432 433**Example** 434 435```ts 436import { Want } from '@kit.AbilityKit'; 437 438let wantTemp: Want = { 439 // Replace it as required. 440 bundleName: 'com.example.edmtest', 441 abilityName: 'com.example.edmtest.EnterpriseAdminAbility' 442}; 443try { 444 let result: Array<wifiManager.WifiAccessInfo> = wifiManager.getDisallowedWifiList(wantTemp); 445 console.info(`Succeeded in getting disallowed wifi list. Result: ${JSON.stringify(result)}`); 446} catch (err) { 447 console.error(`Failed to get disallowed wifi list. Code: ${err.code}, message: ${err.message}`); 448} 449``` 450 451## WifiAccessInfo<sup>19+</sup> 452 453Represents Wi-Fi access information containing Service Set Identifier (SSID) and Basic Service Set Identifier (BSSID). 454 455**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 456 457 458 459| Name | Type | Read-Only| Optional| Description | 460| ------------- | --------------------------------| ---- | -----| ------------------------------------------------------ | 461| ssid | string | No | No| Name of the Wi-Fi hotspot. The encoding format is UTF-8 and the maximum length is 32 bytes (three bytes for each Chinese character and one byte for each English character). | 462| bssid | string | No | Yes| MAC address of the Wi-Fi hotspot, for example, **00:11:22:33:44:55**.<br>This field is mandatory when [addAllowedWifiList](#wifimanageraddallowedwifilist19) and [removeAllowedWifiList](#wifimanagerremoveallowedwifilist19) are called.<br>This field is optional (the default value is an empty string) when [addDisallowedWifiList](#wifimanageradddisallowedwifilist19) and [removeDisallowedWifiList](#wifimanagerremovedisallowedwifilist19) are called. | 463 464## WifiProfile 465 466Represents the Wi-Fi configuration information. 467 468**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 469 470 471 472| Name | Type | Read-Only| Optional| Description | 473| ------------- | ----------------------------------| ---- | ----| ------------------------------------------------------- | 474| ssid | string | No | No| SSID of the hotspot, in UTF-8 format. | 475| bssid | string | No | Yes| Basic service set identifier (BSSID) of the hotspot. | 476| preSharedKey | string | No | No| Pre-shared key (PSK) of the hotspot. | 477| isHiddenSsid | boolean | No | Yes| Whether the network is hidden. The value **true** indicates that the network is hidden; the value **false** indicates the opposite.| 478| securityType | [WifiSecurityType](#wifisecuritytype) | No | No| Security type. | 479| creatorUid | number | No | Yes| ID of the creator. | 480| disableReason | number | No | Yes| Reason for disabling Wi-Fi. | 481| netId | number | No | Yes| Network ID allocated. | 482| randomMacType | number | No | Yes| Random MAC. | 483| randomMacAddr | string | No | Yes| Random MAC address. | 484| ipType | [IpType](#iptype) | No | Yes| IP address type. | 485| staticIp | [IpProfile](#ipprofile) | No | Yes| Static IP address information. | 486| eapProfile | [WifiEapProfile](#wifieapprofile) | No | Yes| Extensible Authentication Protocol (EAP) configuration. | 487 488## WifiSecurityType 489 490Enumerates the Wi-Fi security types. 491 492**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 493 494 495 496| Name | Value | Description | 497| ------------------------- | ---- | ------------------------------------------------------------ | 498| WIFI_SEC_TYPE_INVALID | 0 | Invalid security type. | 499| WIFI_SEC_TYPE_OPEN | 1 | Open security type. | 500| WIFI_SEC_TYPE_WEP | 2 | Wired Equivalent Privacy (WEP). | 501| WIFI_SEC_TYPE_PSK | 3 | PSK. | 502| WIFI_SEC_TYPE_SAE | 4 | Simultaneous Authentication of Equals (SAE).| 503| WIFI_SEC_TYPE_EAP | 5 | EAP. | 504| WIFI_SEC_TYPE_EAP_SUITE_B | 6 | Suite B 192-bit encryption. | 505| WIFI_SEC_TYPE_OWE | 7 | Opportunistic Wireless Encryption (OWE). | 506| WIFI_SEC_TYPE_WAPI_CERT | 8 | WLAN Authentication and Privacy Infrastructure (WAPI) in certificate-based mode (WAPI-CERT). | 507| WIFI_SEC_TYPE_WAPI_PSK | 9 | WAPI-PSK. | 508 509## IpType 510 511Enumerates the IP address types. 512 513**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 514 515 516 517| Name | Value | Description | 518| ------- | ---- | -------------- | 519| STATIC | 0 | Static IP address. | 520| DHCP | 1 | IP address allocated by DHCP.| 521| UNKNOWN | 2 | Not specified. | 522 523## IpProfile 524 525Represents IP configuration information. 526 527**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 528 529 530 531| Name | Type | Mandatory| Description | 532| ------------ | ------------------- | ---- | ----------- | 533| ipAddress | number | Yes | IP address. | 534| gateway | number | Yes | Gateway. | 535| prefixLength | number | Yes | Subnet mask. | 536| dnsServers | number[] | Yes | Domain name server (DNS) information.| 537| domains | Array<string> | Yes | Domain information. | 538 539## WifiEapProfile 540 541Represents EAP profile (configuration) information. 542 543**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 544 545 546 547| Name | Type | Read-Only| Optional| Description | 548| ----------------- | ----------------------------- | ---- |----| -------------------------------- | 549| eapMethod | [EapMethod](#eapmethod) | No | No| EAP authentication method. | 550| phase2Method | [Phase2Method](#phase2method) | No | No| Phase 2 authentication method. | 551| identity | string | No | No| Identity Information. | 552| anonymousIdentity | string | No | No| Anonymous identity. | 553| password | string | No | No| Password. | 554| caCertAliases | string | No | No| CA certificate alias. | 555| caPath | string | No | No| CA certificate path. | 556| clientCertAliases | string | No | No| Client certificate alias. | 557| certEntry | Uint8Array | No | No| CA certificate content. | 558| certPassword | string | No | No| CA certificate password. | 559| altSubjectMatch | string | No | No| A string to match the alternate subject. | 560| domainSuffixMatch | string | No | No| A string to match the domain suffix. | 561| realm | string | No | No| Realm for the passpoint credential. | 562| plmn | string | No | No| Public land mobile network (PLMN) of the passpoint credential provider.| 563| eapSubId | number | No | No| Sub-ID of the SIM card. | 564 565## EapMethod 566 567Enumerates the EAP authentication methods. 568 569**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 570 571 572 573| Name | Value | Description | 574| -------------- | ---- | ---------------- | 575| EAP_NONE | 0 | Not specified. | 576| EAP_PEAP | 1 | PEAP. | 577| EAP_TLS | 2 | TLS. | 578| EAP_TTLS | 3 | TTLS. | 579| EAP_PWD | 4 | Password. | 580| EAP_SIM | 5 | SIM. | 581| EAP_AKA | 6 | AKA. | 582| EAP_AKA_PRIME | 7 | AKA Prime. | 583| EAP_UNAUTH_TLS | 8 | UNAUTH TLS.| 584 585## Phase2Method 586 587Enumerates the Phase 2 authentication methods. 588 589**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 590 591 592 593| Name | Value | Description | 594| ---------------- | ---- | --------------- | 595| PHASE2_NONE | 0 | Not specified. | 596| PHASE2_PAP | 1 | PAP. | 597| PHASE2_MSCHAP | 2 | MS-CHAP. | 598| PHASE2_MSCHAPV2 | 3 | MS-CHAPv2. | 599| PHASE2_GTC | 4 | GTC. | 600| PHASE2_SIM | 5 | SIM. | 601| PHASE2_AKA | 6 | AKA. | 602| PHASE2_AKA_PRIME | 7 | AKA Prime.| 603 604## wifiManager.turnOnWifi<sup>20+</sup> 605 606turnOnWifi(admin: Want, isForce: boolean): void 607 608Enables Wi-Fi. 609 610Wi-Fi cannot be enabled using this API in the following scenario: 611 612 Wi-Fi has been disabled using the [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy) API. You must call [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy) to enable it. 613 614**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 615 616**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 617 618 619 620**Parameters** 621 622| Name | Type | Mandatory| Description | 623| ------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 624| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 625| isForce | boolean | Yes | Whether to forcibly enable Wi-Fi.<br>The value **true** means to forcibly Wi-Fi. Once enabled, it cannot be disabled manually. You must call [turnOffWifi](#wifimanagerturnoffwifi20) instead. The value **false** means the opposite and the Wi-Fi can be disabled manually.| 626 627**Error codes** 628 629For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 630 631| ID| Error Message | 632| -------- | ------------------------------------------------------------ | 633| 9200001 | The application is not an administrator application of the device. | 634| 9200002 | The administrator application does not have permission to manage the device. | 635| 201 | Permission verification failed. The application does not have the permission required to call the API. | 636| 203 | This function is prohibited by enterprise management policies. | 637 638**Example** 639 640```ts 641import { Want } from '@kit.AbilityKit'; 642import { wifiManager } from '@kit.MDMKit'; 643 644let wantTemp: Want = { 645 bundleName: 'com.example.myapplication', 646 abilityName: 'EntryAbility', 647}; 648 649try { 650 wifiManager.turnOnWifi(wantTemp, true); 651 console.info(`Succeeded in turning on wifi.`); 652} catch (err) { 653 console.error(`Failed to turn on wifi. Code: ${err.code}, message: ${err.message}`); 654} 655``` 656 657## wifiManager.turnOffWifi<sup>20+</sup> 658 659turnOffWifi(admin: Want): void 660 661Disables Wi-Fi. 662 663Wi-Fi cannot be disabled using this API in the following scenario: 664 665 Wi-Fi has been disabled using the [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy) API. You must call [setDisallowedPolicy](js-apis-enterprise-restrictions.md#restrictionssetdisallowedpolicy) to enable it. 666 667**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_WIFI 668 669**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 670 671 672 673**Parameters** 674 675| Name| Type | Mandatory| Description | 676| ------ | ------------------------------------------------------- | ---- | ---------------------- | 677| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 678 679**Error codes** 680 681For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 682 683| ID| Error Message | 684| -------- | ------------------------------------------------------------ | 685| 9200001 | The application is not an administrator application of the device. | 686| 9200002 | The administrator application does not have permission to manage the device. | 687| 201 | Permission verification failed. The application does not have the permission required to call the API. | 688| 203 | This function is prohibited by enterprise management policies. | 689 690**Example** 691 692```ts 693import { Want } from '@kit.AbilityKit'; 694import { wifiManager } from '@kit.MDMKit'; 695 696let wantTemp: Want = { 697 bundleName: 'com.example.myapplication', 698 abilityName: 'EntryAbility', 699}; 700 701try { 702 wifiManager.turnOffWifi(wantTemp); 703 console.info(`Succeeded in turning off wifi.`); 704} catch (err) { 705 console.error(`Failed to turn off wifi. Code: ${err.code}, message: ${err.message}`); 706} 707``` 708