connecting from a C program under Windows

Service Informatique CHSR chsrinfo at guetali.fr
Sun Jun 14 22:21:56 GMT 1998


Hello,
This question is only partly related to Samba, so I apology, but I do
believe that someone among you is able to answer me.

I want to connect a network drive to a samba share (security = user) from a
C program under Windows 95. Here is the code:

---------8<-------------
NETRESOURCE nr;
DWORD result;
LPSTR user="someuser", password="pass";

nr.dwType=RESOURCETYPE_DISK;
nr.lpLocalName="X:";
nr.lpRemoteName="\\\\SERVER\\SHARE";
nr.lpProvider=NULL;
result=WNetAddConnection2(&nr, user, password,0);
---------8<-------------

But the result is always ERROR_INVALID_PASSWORD, as if it fails in
SMBsessionsetupX. I think so because after I do any connection from the
Windows 95 explorer to SERVER, my code successfully connect to any share
with *any* user/password pair.
So, I believe WNetAddConnection2 works in a security = share manner.
Does anyone know how to do the trick?

Regards,
Jephte CLAIN




More information about the samba mailing list