-
Jun 23rd, 2020, 07:15 AM
#1
Thread Starter
New Member
How to clear network drive credentials in vb.net?
in windows, you can see Stored User Names and Passwords by running rundll32.exe keymgr.dll, KRShowKeyMgr in cmd. Then, you can select a specific network drive and Remove its credentials.
Is there a way to clear specific network drive's credentials programatically in .net? either by running some shell command, creating a process, or by importing some .net library?
Last edited by mshaemadafa; Jun 23rd, 2020 at 09:09 AM.
-
Jun 23rd, 2020, 09:21 AM
#2
Re: How to clear network drive credentials in vb.net?
this sounds fishy to me,
why not ask the network administrator
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Jun 23rd, 2020, 09:31 AM
#3
Thread Starter
New Member
Re: How to clear network drive credentials in vb.net?
well I am the network administrator, and I'm trying to build the program that would let users clear network drive's credentials on their own. For instance, someone is logged on \\abcdefg\shared with Account1( username1, password1). Account2(username2, password2) has different privileges, and at the moment he wants to connect to the network drive with that account. The only way to disconnect from \\abcdefg\shared is to clear the network drive credentials using keymgr.dll.
Even if user won't ever switch the accounts, I still want him to be able to disconnect from the network drive completely, and for that, clearing the network credentials is an essential step. Even when I delete the network drive by net use \\abcdefg\shared \delete, username and password is still cached, and needs to be cleared using keymgr.dll
Of course I can run rundll32.exe keymgr.dll, KRShowKeyMgr using Shell command and ask users to clear the network credentials on their own, but it's risky as they might accidentally delete something else.
Last edited by mshaemadafa; Jun 23rd, 2020 at 01:04 PM.
-
Jun 23rd, 2020, 11:13 AM
#4
Re: How to clear network drive credentials in vb.net?
I can certainly see the point. I'm glad I don't deal with that stuff, though. I would expect that it would be possible. Hopefully, somebody who has dealt with this more will have an answer.
My usual boring signature: Nothing
-
Jun 23rd, 2020, 11:38 AM
#5
Re: How to clear network drive credentials in vb.net?
here a Link to Powershell
https://gallery.technet.microsoft.co...lsPas-981564bf
or with the CMDKey
put this in a Batchfile
Code:
For /F “tokens=1,2 delims= ” %%G in (‘cmdkey /list ^| findstr Target’) do cmdkey /delete %%H
see if it picks up everything
good luck
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Jun 23rd, 2020, 11:57 AM
#6
Re: How to clear network drive credentials in vb.net?
You can add AdysTech.CredentialManager NuGet library and then use it as follows:
VB.NET Code:
Imports AdysTech.CredentialManager
...
CredentialManager.RemoveCredentials("192.168.x.x", CredentialType.Windows)
...
You have to set the proper target name (192.168.x.x).
If you don't want full credentials management (e.g. enumerating all credentials, etc.), you can just declare the external function:
VB.NET Code:
Public Declare Unicode Function CredDelete Lib "advapi32.dll" Alias "CredDeleteW" (ByVal TargetName As String, ByVal Type As Integer, ByVal Flags As Integer) As Boolean
...
Dim success = CredDelete("192.168.x.x", 2, 0)
...
In the CredDelete the parameter 2 means "domain password". Read more on pInvoke.net site.
-
Jun 23rd, 2020, 06:11 PM
#7
Re: How to clear network drive credentials in vb.net?
-
Jun 24th, 2020, 08:18 AM
#8
Thread Starter
New Member
Re: How to clear network drive credentials in vb.net?
peterst,
Originally Posted by peterst
You can add AdysTech.CredentialManager NuGet library and then use it as follows:
VB.NET Code:
Imports AdysTech.CredentialManager
...
CredentialManager.RemoveCredentials("192.168.x.x", CredentialType.Windows)
...
You have to set the proper target name (192.168.x.x).
This is perfect! works flawlessly. Thanks!
ident and ChrisE's answers seem to be a proper solution, too but probably this is the simplest way.
Last edited by mshaemadafa; Jun 24th, 2020 at 08:24 AM.
-
Jun 24th, 2020, 08:34 AM
#9
Re: How to clear network drive credentials in vb.net?
Originally Posted by mshaemadafa
peterst,
This is perfect! works flawlessly. Thanks!
I agree, looks like it is easy to use
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|