Authentication of Shared Drive Programatically

My application requires to copy data to \\yourUNC\path which is password protected
My application is aware of the UserName and Password.
If I use

Net Use \\yourUNC\path /username password

then that Share will be accessible from Windows Explorer too until it is deleted which is a security lapse.

I Use Delphi Xe2 with Windows OS
Allan_FernandesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
Can use add into your application, to delete the connection...
Net Use \\yourUNC\path /delete
0
Allan_FernandesAuthor Commented:
But During Execution of the program  the folder can be misused by other users
0
NVITCommented:
can you do without using Net Use?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

NVITCommented:
NET USE will be connected as the user that runs your program. If the user is an admin, then it connects as admin. If as the user, then connects as the user.

Who is it run as?
0
Allan_FernandesAuthor Commented:
Mine is a backup application and will be loaded as a Std User. I would prefer that the code is within my application. For Your Information, I also have a service running in Local System and there is a centrally located UI module wherein I can ask and store all required User names , passwords etc.
0
purpleoakCommented:
you can use

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "T:", \\MyServer\MyData
0
David Johnson, CD, MVPOwnerCommented:
you don't need to "Net use a share you can just reference the unc path
0
Sinisa VukCommented:
you need something like RunAs.....copy \\dd\ee\*.txt \dest
Look at old EE question...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.