-
Mar 12th, 2014, 08:08 AM
#1
Thread Starter
Registered User
Accessing Windows Security through Visual Basic
I've created a code that copies the folder contents from PC1(pc for user) to PC2(pc for server). I used Active Directory to create accounts for the access of PC2's server
I have the ff code to transfer from PC1 to PC2:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
My.Computer.FileSystem.CopyDirectory("C:\Users\Bounty Hounds\Desktop\1", "\\WIN-2I9JBRPFMO7\UserFiles\joshua824\Desktop\joshua824", True)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
My.Computer.FileSystem.CopyDirectory("\\WIN-2I9JBRPFMO7\UserFiles\joshua824\Desktop\joshua824", "C:\Users\Bounty Hounds\Desktop\1", True)
End Sub
End Class
That code only works if you pass the server's login information that only seems to show when I try to manually enter the address of the server
I found two ways to approach this problem
First
1. Create a login form
2. Second form would tell Windows Security via vb code that my username and password are what I inputted on the login form
Second
1. Create a code that will show Windows Security automatically when running my visual basic program
However i'm struggling on how do I tell Windows Security about my login info and at the same time I don't know how do I manually show Windows Security
-
Mar 12th, 2014, 11:16 AM
#2
Re: Accessing Windows Security through Visual Basic
You should map the network share to a local drive, even you don't use it, and then disconnect the mapped drive after you're done with the copying. Why? because code examples for mapping network drives with credentials are readily available on the Internet, or you simply start a process and run net use command. Once the share is mapped, your application can access it via UNC path as it currently is.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Mar 12th, 2014, 01:56 PM
#3
Thread Starter
Registered User
Re: Accessing Windows Security through Visual Basic
Originally Posted by stanav
You should map the network share to a local drive, even you don't use it, and then disconnect the mapped drive after you're done with the copying. Why? because code examples for mapping network drives with credentials are readily available on the Internet, or you simply start a process and run net use command. Once the share is mapped, your application can access it via UNC path as it currently is.
Thanks so much for answering, while waiting for the answer previously I found out about the net use command via cmd and planned to:
1. Create a login form that will store the values of username, password
2. Create a .txt file via vb with the text file containing "net use"
3. Add the variable of username and password into the .txt file like: net use + "& username & password" to create the code "net use /username password" command
4. Convert it to bat
5. Run it
That's how I thought of reaching the server's locked connection.
I've encountered a new problem though, by using the net use command. I don't know how to log off, I've tried using net use * /delete but I can still access the shared path. Temporary solution to log off the network would be restarting the computer which is really troublesome.
-
Mar 12th, 2014, 03:07 PM
#4
Addicted Member
Re: Accessing Windows Security through Visual Basic
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
|