CredWrite restituisce codice di errore Win32 2 (ERROR_INVALID_FUNCTION) “Funzione non corretta.”

StackOverflow https://stackoverflow.com/questions/2337672

  •  22-09-2019
  •  | 
  •  

Domanda

sto provando a chiamare CredWrite , ma sta tornando ERROR_INVALID_FUNCTION . posso chiamare CredRead per recuperare le credenziali di la memorizzazione delle password, e io in grado di memorizzare le nuove credenziali utilizzando CredUIPromptForCredentials .

Ma io non riesco a capire come ottenere CredWrite funzionare.

Il codice che sto utilizzando è:

var
   Target, Username, Password: WideString;
begin
   Target := 'StackOverflowSomething';
   Username := 'IanBoyd'; 
   Password := 'password69';

   ZeroMemory(@Credentials, SizeOf(Credentials));

   Credentials.TargetName := PWideChar(Target);
   Credentials.Type_ := CRED_TYPE_GENERIC;
   Credentials.UserName := PWideChar(Username);
   Credentials.Persist := CRED_PERSIST_ENTERPRISE;
   Credentials.CredentialBlob := PByte(Password);
   Credentials.CredentialBlobSize := 2*(Length(Password));
   Credentials.UserName := PWideChar(Username);

   if not CredWriteW(@Credentials, 0) then
      RaiseLastWin32Error;

E GetLastError sta tornando 1 (ERROR_INVALID_FUNCTION)

E 'questa funzione non è corretto? Non è nemmeno il ritorno ERROR_INVALID_PARAMETER, è il ritorno "Funzione non corretta". Che cosa non è corretta?

Esiste un codice di esempio là fuori che chiama CredWrite?

Note

  • ho provato a chiamare la versione Ansi (CredWriteA), stesso risultato
  • Ho provato con CRED_PERSIST_SESSION e CRED_PERSIST_LOCAL_MACHINE, oltre a CRED_PERSIST_ENTERPRISE
È stato utile?

Soluzione

Non importa, ho capito.

E non è colpa del chiamata API, oppure i miei parametri.

Sono solo stupido.

E voglio tenere il broncio fuori, senza dover dire quello che ho fatto: (

Altri suggerimenti

Non dovrebbe questo

 Credentials.Type_ := CRED_TYPE_GENERIC;

Puoi essere questo, invece?

 Credentials.Type := CRED_TYPE_GENERIC;

Sono curioso, questo è per la smart card, giusto? e il gioco è come conservare il perno no alla smart card, forse l'allegato / driver non viene caricato per la credwrite al lavoro? Forse, con una smartcard hardware / software standard definito utilizzato da Windows attiverà la funzione CredWrite, la mia ipotesi è che CredWrite sta tentando di comunicare con qualcosa (forse una chiamata API generica a una funzione standard all'interno l'hardware smart card?) ... basta i miei pensieri ...

Spero che questo aiuti, I migliori saluti, Tom.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top