Export (0) Print
Expand All
Expand Minimize

CredEnumerate function

The CredEnumerate function enumerates the credentials from the user's credential set. The credential set used is the one associated with the logon session of the current token. The token must not have the user's SID disabled.

Syntax


BOOL CredEnumerate(
  _In_   LPCTSTR Filter,
  _In_   DWORD Flags,
  _Out_  DWORD *Count,
  _Out_  PCREDENTIAL **Credentials
);

Parameters

Filter [in]

Pointer to a null-terminated string that contains the filter for the returned credentials. Only credentials with a TargetName matching the filter will be returned. The filter specifies a name prefix followed by an asterisk. For instance, the filter "FRED*" will return all credentials with a TargetName beginning with the string "FRED".

If NULL is specified, all credentials will be returned.

Flags [in]

The value of this parameter can be zero or more of the following values combined with a bitwise-OR operation.

ValueMeaning
CRED_ENUMERATE_ALL_CREDENTIALS
0x1

This function enumerates all of the credentials in the user's credential set. The target name of each credential is returned in the "namespace:attribute=target" format. If this flag is set and the Filter parameter is not NULL, the function fails and returns ERROR_INVALID_FLAGS.

Windows Server 2003 and Windows XP:  This flag is not supported.

 

Count [out]

Count of the credentials returned in the Credentials array.

Credentials [out]

Pointer to an array of pointers to credentials. The returned credential is a single allocated block. Any pointers contained within the buffer are pointers to locations within this single allocated block. The single returned buffer must be freed by calling CredFree.

Return value

The 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 codes can be returned.

Return code/valueDescription
ERROR_NOT_FOUND
1168 (0x490)

No credential exists matching the specified Filter.

ERROR_NO_SUCH_LOGON_SESSION
1312 (0x520)

The logon session does not exist or there is no credential set associated with this logon session. Network logon sessions do not have an associated credential set.

ERROR_INVALID_FLAGS
1004 (0x3EC)

A flag that is not valid was specified for the Flags parameter, or CRED_ENUMERATE_ALL_CREDENTIALS is specified for the Flags parameter and the Filter parameter is not NULL.

 

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

CredEnumerateW (Unicode) and CredEnumerateA (ANSI)

See also

CredFree
GetLastError

 

 

Community Additions

ADD
Show:
© 2014 Microsoft