Microsoft.Alm.Authentication.NativeMethods.CredDelete C# (CSharp) Method

CredDelete() private method

private CredDelete ( string targetName, CredentialType type, uint flags ) : bool
targetName string
type CredentialType
flags uint
return bool
        internal static extern bool CredDelete(string targetName, CredentialType type, uint flags);

Usage Example

Esempio n. 1
0
        protected void PurgeCredentials(string @namespace)
        {
            string filter = @namespace + "*";
            int    count;
            IntPtr credentialArrayPtr;

            if (NativeMethods.CredEnumerate(filter, 0, out count, out credentialArrayPtr))
            {
                for (int i = 0; i < count; i += 1)
                {
                    int    offset        = i * Marshal.SizeOf(typeof(IntPtr));
                    IntPtr credentialPtr = Marshal.ReadIntPtr(credentialArrayPtr, offset);

                    if (credentialPtr != IntPtr.Zero)
                    {
                        NativeMethods.Credential credential = Marshal.PtrToStructure <NativeMethods.Credential>(credentialPtr);

                        if (!NativeMethods.CredDelete(credential.TargetName, credential.Type, 0))
                        {
                            int error = Marshal.GetLastWin32Error();
                            Debug.Fail("Failed with error code " + error.ToString("X"));
                        }
                    }
                }

                NativeMethods.CredFree(credentialArrayPtr);
            }
            else
            {
                int error = Marshal.GetLastWin32Error();
                Debug.Fail("Failed with error code " + error.ToString("X"));
            }
        }
All Usage Examples Of Microsoft.Alm.Authentication.NativeMethods::CredDelete