/// <summary> /// Remove stored credentials from windows credential store /// </summary> /// <param name="Target">Name of the application/Url where the credential is used for</param> /// <returns>True: Success, False: Failure</returns> public static bool RemoveCredentials(string Target) { // Make the API call using the P/Invoke signature var ret = NativeCode.CredDelete(Target, NativeCode.CredentialType.Generic, 0); int lastError = Marshal.GetLastWin32Error(); if (!ret) { throw new Win32Exception(lastError, "CredDelete throw an error"); } return(ret); }
public bool RemoveCredential() { // Make the API call using the P/Invoke signature var isSuccess = NativeCode.CredDelete(TargetName, (uint)Type, 0); if (isSuccess) { return(true); } int lastError = Marshal.GetLastWin32Error(); throw new CredentialAPIException($"Unable to Delete Credential", "CredDelete", lastError); }
/// <summary> /// Remove stored credentials from windows credential store /// </summary> /// <param name="target">Name of the application/Url where the credential is used for</param> /// <returns>True: Success, throw if failed</returns> public static bool RemoveCredentials(string target, CredentialType type = CredentialType.Generic) { // Make the API call using the P/Invoke signature var isSuccess = NativeCode.CredDelete(target, (UInt32)type, 0); if (isSuccess) { return(true); } int lastError = Marshal.GetLastWin32Error(); throw new CredentialAPIException($"Unable to Delete Credential", "CredDelete", lastError); }
/// <summary> /// Remove stored credentials from windows credential store /// </summary> /// <param name="target">Name of the application/Url where the credential is used for</param> /// <returns>True: Success, throw if failed</returns> public static bool RemoveCredentials(string target) { // Make the API call using the P/Invoke signature var isSuccess = NativeCode.CredDelete(target, NativeCode.CredentialType.Generic, 0); if (isSuccess) { return(true); } int lastError = Marshal.GetLastWin32Error(); throw new Win32Exception(lastError, String.Format("'CredDelete' call throw an error (Error code: {0})", lastError)); }