Export (0) Print
Expand All
Expand Minimize

CredMarshalCredential function

The CredMarshalCredential function transforms a credential into a text string. Historically, many functions, such as NetUseAdd, take a domain name, user name, and password as credentials. These functions do not accept certificates as credentials. The CredMarshalCredential function converts such credentials into a form that can be passed into these APIs.

The marshaled credential should be passed as the user name string to any API that is currently passed credentials. The domain name, if applicable, passed to that API should be passed as NULL or empty. For certificate credentials, the PIN of the certificate should be passed to that API as the password.

The caller should not modify or print marshaled credentials. The returned value can be freely converted between the Unicode, ANSI, and OEM characters sets. The string is case sensitive.

Syntax


BOOL CredMarshalCredential(
  _In_   CRED_MARSHAL_TYPE CredType,
  _In_   PVOID Credential,
  _Out_  LPTSTR *MarshaledCredential
);

Parameters

CredType [in]

Type of the credential to marshal.

Credential [in]

Credential to marshal. This is one of the CRED_MARSHAL_TYPE values.

If CredType is CertCredential, Credential points to a CERT_CREDENTIAL_INFO structure.

If CredType is UsernameTargetCredential, Credential points to a USERNAME_TARGET_CREDENTIAL_INFO structure.

MarshaledCredential [out]

Pointer to a null-terminated string that contains the marshaled credential. The caller should free the returned buffer using CredFree.

Return value

This function returns TRUE on success and FALSE on failure. The GetLastError function can be called to get a more specific status code. The following status code can be returned:

ERROR_INVALID_PARAMETER

CredType is not valid.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

WinCred.h

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

CredMarshalCredentialW (Unicode) and CredMarshalCredentialA (ANSI)

See also

CredFree
CredUnmarshalCredential
CRED_MARSHAL_TYPE
CERT_CREDENTIAL_INFO
GetLastError
USERNAME_TARGET_CREDENTIAL_INFO

 

 

Community Additions

ADD
Show:
© 2014 Microsoft