NetAddServiceAccount function

The NetAddServiceAccount function creates a standalone managed service account (sMSA) or retrieves the credentials for a group managed service account (gMSA) and stores the account information on the local computer.

This function has no associated import library. You must use the LoadLibrary and GetProcAddress functions to dynamically link to Logoncli.dll.

Windows Server 2008 R2:  Installing a managed service account by using the Windows PowerShell command line interface cmdlet to call this function fails with error code 0xC0000225 when the value of the AccountName parameter does not match the corresponding Security Accounts Manager (SAM) name of the account.

Syntax


NTSTATUS WINAPI NetAddServiceAccount(
  _In_opt_  LPWSTR ServerName,
  _In_      LPWSTR AccountName,
  _In_      LPWSTR Reserved,
  _In_      DWORD Flags
);

Parameters

ServerName [in, optional]

The value of this parameter must be NULL.

AccountName [in]

The name of the account to be created.

Reserved [in]

This parameter is reserved. Do not use it.

Flags [in]

This parameter can be the following value.

ValueMeaning
SERVICE_ACCOUNT_FLAG_LINK_TO_HOST_ONLY
0x00000001

No standalone managed service account is created. If a service account with the specified name exists, it is linked to the local computer. This flag is ignored if the account name is an existing gMSA.

 

Return value

If the function succeeds, it returns STATUS_SUCCESS.

If the function fails, it returns an error code.

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Lmaccess.h

DLL

Netapi32.dll

See also

NetEnumerateServiceAccounts
NetIsServiceAccount
NetRemoveServiceAccount

 

 

Community Additions

ADD
Show:
© 2014 Microsoft