/// <summary>
 /// Get a credential by name.
 /// </summary>
 /// <param name="target_name">The name of the credential.</param>
 /// <param name="type">The type of credential.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The read credential.</returns>
 public static NtResult <Credential> GetCredential(string target_name, CredentialType type, bool throw_on_error)
 {
     return(SecurityNativeMethods.CredRead(target_name, type, 0, out SafeCredBuffer buffer).CreateWin32Result(throw_on_error, () => {
         using (buffer)
         {
             return ParseCredential(buffer.DangerousGetHandle());
         }
     }));
 }