Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CredDelete requires Type even if input object is <class 'dict'> from CredEnumerate #1775

Closed
mavaddat opened this issue Oct 16, 2021 · 2 comments

Comments

@mavaddat
Copy link

mavaddat commented Oct 16, 2021

Expected behavior and actual behavior.

I would expect win32cred.CredDelete method be capable of deleting a credential from the credential store without Type specification iff the Target input is <class 'dict'> with key 'Type' having a value of type int.

Instead, there is no overloaded win32cred.CredDelete to handle single parameter of credential object as dictionary.

Traceback (most recent call last):
TypeError: CredDelete() missing required argument 'Type' (pos 2)

Steps to reproduce the problem.

Loop through the credential store to find and delete ones added by keyring Python module. Example code:

import keyring
import win32cred

keyring.set_password('system','me','password')

for cred in win32cred.CredEnumerate():
    if cred['Comment']=='Stored using python-keyring':
        win32cred.CredDelete(cred)

Version of Python and pywin32

Package Version
Python 3.9.6
pywin32 302

Work-around

In the example loop above, simply provide the TargetName and Type values as the two arguments to CredDelete.

for cred in win32cred.CredEnumerate():
    if cred['Comment']=='Stored using python-keyring':
        win32cred.CredDelete(cred['TargetName'],cred['Type'])

Possible resolution

It looks like we just need for PyCredDelete to be able to check if the Target is a dictionary object, then extract the Type attribute.

// @pymethod |win32cred|CredDelete|Deletes a stored credential

@mhammond
Copy link
Owner

I'd welcome a PR for this.

@Avasam
Copy link
Collaborator

Avasam commented Mar 17, 2024

Closed by #2198

@Avasam Avasam closed this as completed Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants