Results 1 to 6 of 6

Thread: Network Authentication in VB 2005

  1. #1

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    59

    Network Authentication in VB 2005

    Hi, I tried to connect to a network shared folder (actually i share my access db in the network) but i couldn't make it connected unless i map it in every pc that will use my prog. i am trying not to map it for some other reasons. What I'm trying to say is upon loading my startup form or my application, the network authentication window should appear first just like when you do "RUN", "\\IPAddress\SharedFolderName$\dbname.mdb".

    Rgds...

  2. #2
    New Member
    Join Date
    Sep 2008
    Posts
    2

    Re: Network Authentication in VB 2005

    I have excacly the same problem

    Hi to all
    Please forgive me but i am a noob to the exciting word of programming

    I try to make a VB2008 with framework 2.0 and 3.5 project that will connect to my other local computer and download a file

    when i press start from windows -> run -> \\mypc2\c$ it prompts me about my username and password , i enter them and i can see all the c: drive of my remote computer and download the data, even when i use the code emmidietly:
    my.computer.network.downloadfile("\\mypc2\c$\text.txt", "c:\test.txt", username,password) it works fine , but if i reboot my computrer and run my project i get the responce "wrong username or bad password" again and again


    I need some cind of network credentials or something else?
    please advice us the noobs

  3. #3

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    59

    Re: Network Authentication in VB 2005

    hi jimiol, tnx for sharing the same issue. btw, u can temporarily use the WNetAddConnection2 by mapping your target shared file.
    In my case, as much as possible, I will not use the map option. I'm trying to use either WNetAddConnection3 orWNetConnectionDialog but until now I couldn't make a correct code, I was stucked by this PInvoke error.

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Network Authentication in VB 2005

    Not the most elegant solution but I would just Shell the Net Use command to authenticate you before running the part of your program that needs to access that folder. So for example:

    vb Code:
    1. Shell("Net Use \\IPADDRESS\Share /user:UsernameHere PasswordHere", AppWinStyle.Hide, True, 10000)
    This code will create a connection to the specified shared folder with the credentials you provide by using the Net.exe program that is included with Windows. The arguments after the net use command are just telling the program to not display the command prompt window that would normally appear when running Net.exe and it also tells the program to wait for the net.exe program to complete its operation (unless this exceeds 10000 miliseconds - 10 seconds)

    Hope that helps
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5
    New Member
    Join Date
    Sep 2008
    Posts
    2

    Re: Network Authentication in VB 2005

    Quote Originally Posted by chris128
    Not the most elegant solution but I would just Shell the Net Use command to authenticate you before running the part of your program that needs to access that folder. So for example:

    vb Code:
    1. Shell("Net Use \\IPADDRESS\Share /user:UsernameHere PasswordHere", AppWinStyle.Hide, True, 10000)
    This code will create a connection to the specified shared folder with the credentials you provide by using the Net.exe program that is included with Windows. The arguments after the net use command are just telling the program to not display the command prompt window that would normally appear when running Net.exe and it also tells the program to wait for the net.exe program to complete its operation (unless this exceeds 10000 miliseconds - 10 seconds)

    Hope that helps
    Chris worked like a charm!
    You are a lifesaver, you solved my problem and now my project works perfect every time.

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Network Authentication in VB 2005

    glad I could help
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width