WlanSaveTemporaryProfile function (wlanapi.h)

The WlanSaveTemporaryProfile function saves a temporary profile to the profile store.

Syntax

DWORD WlanSaveTemporaryProfile(
  [in]           HANDLE     hClientHandle,
  [in]           const GUID *pInterfaceGuid,
  [in]           LPCWSTR    strProfileName,
  [in, optional] LPCWSTR    strAllUserProfileSecurity,
  [in]           DWORD      dwFlags,
  [in]           BOOL       bOverWrite,
                 PVOID      pReserved
);

Parameters

[in] hClientHandle

The client's session handle, obtained by a previous call to the WlanOpenHandle function.

[in] pInterfaceGuid

The GUID of the interface.

[in] strProfileName

The name of the profile to be saved. Profile names are case-sensitive. This string must be NULL-terminated.

[in, optional] strAllUserProfileSecurity

Sets the security descriptor string on the all-user profile. By default, for a new all-user profile, all users have write access on the profile. For more information about profile permissions, see the Remarks section.

If dwFlags is set to WLAN_PROFILE_USER, this parameter is ignored.

If this parameter is set to NULL for an all-user profile, the default permissions are used.

If this parameter is not NULL for an all-user profile, the security descriptor string associated with the profile is created or modified after the security descriptor object is created and parsed as a string.

[in] dwFlags

Specifies the flags to set on the profile. The flags can be combined.

Value Meaning
0
The profile is an all-user profile.
WLAN_PROFILE_USER
0x00000002
The profile is a per-user profile.
WLAN_PROFILE_CONNECTION_MODE_SET_BY_CLIENT
0x00010000
The profile was created by the client.
WLAN_PROFILE_CONNECTION_MODE_AUTO
0x00020000
The profile was created by the automatic configuration module.

[in] bOverWrite

Specifies whether this profile is overwriting an existing profile. If this parameter is FALSE and the profile already exists, the existing profile will not be overwritten and an error will be returned.

pReserved

Reserved for future use. Must be set to NULL.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value may be one of the following return codes.

Return code Description
ERROR_INVALID_PARAMETER
One of the following conditions occurred:
  • hClientHandle is NULL or invalid.
  • pInterfaceGuid is NULL.
  • pReserved is not NULL.
  • dwFlags is not set to a combination of one or more of the values specified in the table above.
  • dwFlags is set to WLAN_PROFILE_CONNECTION_MODE_AUTO and strProfileName is NULL.
ERROR_INVALID_HANDLE
The handle hClientHandle was not found in the handle table.
ERROR_NOT_SUPPORTED
This function was called from an unsupported platform. This value will be returned if this function was called from a Windows XP with SP3 or Wireless LAN API for Windows XP with SP2 client.
RPC_STATUS
Various error codes.
ERROR_INVALID_STATE
The interface is not currently connected using a temporary profile.

Remarks

A temporary profile is the one passed to WlanConnect or generated by the discovery engine. A network connection can be established using a temporary profile. Using this API saves the temporary profile and associated user data to the profile store.

A new profile is added at the top of the list after the group policy profiles. A profile's position in the list is not changed if an existing profile is overwritten.

All-user profiles have three associated permissions: read, write, and execute. If a user has read access, the user can view profile permissions. If a user has execute access, the user has read access and the user can also connect to and disconnect from a network using the profile. If a user has write access, the user has execute access and the user can also modify and delete permissions associated with a profile.

The following describes the procedure for creating a security descriptor object and parsing it as a string.

  1. Call InitializeSecurityDescriptor to create a security descriptor in memory.
  2. Call SetSecurityDescriptorOwner.
  3. Call InitializeAcl to create a discretionary access control list (DACL) in memory.
  4. Call AddAccessAllowedAce or AddAccessDeniedAce to add access control entries (ACEs) to the DACL. Set the AccessMask parameter to one of the following bitwise OR combinations as appropriate:
    • WLAN_READ_ACCESS
    • WLAN_READ_ACCESS | WLAN_EXECUTE_ACCESS
    • WLAN_READ_ACCESS | WLAN_EXECUTE_ACCESS | WLAN_WRITE_ACCESS
  5. Call SetSecurityDescriptorDacl to add the DACL to the security descriptor.
  6. Call ConvertSecurityDescriptorToStringSecurityDescriptor to convert the descriptor to string.
The string returned by ConvertSecurityDescriptorToStringSecurityDescriptor can then be used as the strAllUserProfileSecurity parameter value when calling WlanSaveTemporaryProfile.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header wlanapi.h (include Wlanapi.h)
Library Wlanapi.lib
DLL Wlanapi.dll

See also

Native Wifi API Permissions