Solved

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

Posted on 2008-10-20
7
758 Views
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.
0
Comment
Question by:zambuka42
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:thewild
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

0
 

Author Comment

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

Accepted Solution

by:
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 : http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_22685206.html
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:zambuka42
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.
0
 
LVL 4

Expert Comment

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

Author Comment

by:zambuka42
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
0
 

Author Closing Comment

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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now