Issue
From a Vista workstation, I have an attached XP Embedded computer on which I want to programmatically mount a volume locally (e.g., mount the XP Embedded \\MyXPEmbedded\C:\some\path\
to the Vista workstation (mounted to C:\mounted_XPEmbedded\
).
(This is an administrative utility that runs on the Vista workstation that maintains files on the XP Embedded workstation, which is part of a larger device.)
I can see the XP Embedded computer from the Vista workstation. For example, I can ::getnameinfo()
to resolve the XP Embedded computer's name from its IP address.
However, all calls to GetVolumeNameForVolumeMountPoint()
fail (returns false
), with the formatted message from ::GetLastError()
being:
Logon failure: unknown user name or bad password
So clearly, this seems to be a permissions problem. However, I see no discussion in the Microsoft APIs how I may provide the user/password through these volume GUID path APIs.
When "browsing" the XP Embedded from the Windows Explorer on the Vista workstation by typing the IP address for the XP Embedded machine into the address bar, I get prompted for a user name and password, after which I can see everything on the XP Embedded (duh! How do I provide that programatically?)
QUESTION: How can I provide the user login/password programatically when working with the GUID path APIs (and specifically ::GetVolumeNameForVolumeMountPoint()
)?
Part of the problem may be that these computers do not share the same domain (they can't, the Vista computer will be added to the customer's domain, the XP Embedded must be "hidden").
Other info, which probably is not important:
- The Vista workstation and XP Embedded do not share the same domain (they can't)
- Application runs on Vista workstation under an account with Administrative permissions (I assume this is required?)
- That Vista administrative account is not present on the XP Embedded computer (the XP Embedded has a different administrative account)
- The clocks between both computers are current (security credentials should work)
- The Vista workstation has two network cards, one card connects directly to the XP Embedded box, which has only one network card
- Using C++, MSVS2008
BONUS QUESTION: It would be nice if I could run this administrative utility on the Vista workstation without administrative permissions, is this possible? (I know the administrative login/password for the XP embedded.)
Solution
Make a call to WNetAddConnection2
before trying to access the shares on the embedded box. You might need to have username in the form of MyXPEmbedded\[admin username]
.
You may come across issues if you have already tried to make connections to the embedded box previously. To remove any of the lingering connections you can use, from the command line - net use
with the /delete
option. You can also play with establishing the connection w/ net use before running your program for debugging purposes.
As far as running w/o admin privileges that will mostly have to do with where you decide to make the local mount point, but you could probably get away with just using the UNC path. Using the default administrative shares (which are enabled if "use simple file sharing" is disabled) you can access the embedded system using something like \\MyXPEmbedded\c$\some\path
.
Answered By - daalbert