In VB 6.0, How to append text to file across network using seperate credentials

Posted on 2008-10-20
Last Modified: 2013-11-25
I have a large text file across a network that I need my program to append text to. However, I need it to use a specific set of credentials (user/pass) other than those of the user that has run the program.
Question by:zambuka42
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Expert Comment

ID: 22757359
There might be a nicer and/or easier solution, but I would just map a network drive with your supplied credentials to the remote share, work on the file and remove the share.
The WScript.Network object will do the trick here.
Dim oWshNetwork As Object
Set oWshNetwork = CreateObject("WScript.Network")
oWshNetwork.MapNetworkDrive <DriveLetter>, <\\server\share>, False, <DOMAIN\User>, <Password>
'your code here
oWshNetwork.RemoveNetworkDrive <DriveLetter>, True, False
Set oWshNetwork = Nothing

Open in new window


Author Comment

ID: 22757921
no, I'm afraid that will not work. It is still the user who ran the program's credentials being used.

Accepted Solution

thewild earned 250 total points
ID: 22758125
So that's NTFS credentials, not network share authorizations, right ?
Then maybe you'll have to use impersonation.
This might help :
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 22759729
not sure what you mean by NTFS credentials. Did you mean NTLM credentials? Anyway, you need NTLM credentials to access a share.. however, my program needs to access the share then write to a file. If you simply make a connection to the share using alternate credentials, that is not enough, because the next step is writing to the file which would then occur using the current logged in user, not the alternate credentials. I need to write to the file using the alternate credentials.

Expert Comment

ID: 22765354
Well, isn't it what impersonation is about ? Impersonate another user to use his credentials ?
Have you checked the link I posted ?

Author Comment

ID: 22765489
I do plan on trying it, i was just trying to clear up what I thought might be a misunderstanding. Anyway, I'm afraid I can't get remotely connected to the site I am using this on at the moment, so I won't be able to try it properly until then. I'll repost.. thanks alot for your help

Author Closing Comment

ID: 31507792
The code in the link provided worked very well. Thank you very much

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question