>Hi,
>ENV: WIN95 + VFP5.0 + NetWare 3.12
>I have to programmaticaly log into a NetWare server and I need a ".FLL" or an OCX which allows me to specify user name and password.
>I tried
> - WIN32 WNetAddConnection() and this requires to be logged.
> - GPLIB32 and it seems like some DLLs are missing.
>(CALWIN32, LOCWIN32, NETWIN32 ...
>
>Is there a way to do that?
I tried messing around with this idea last year. I did not get to far with it, but here is some code I came up with. I do not know if works, but its free! You might check out
http://devsup.novell.com/ for sample code. This site was very helpful for finding functions. Also, you can do a QuickView from your windows explorer on any of the DLLs that you mentioned above. This shows you the functions available to be called from FoxPro. I hope it helps.
#DEFINE OT_USER 256 && Object type is user
#DEFINE NWR_ALREADY_ATTACHED 34816 && Attaching to a server already connected
#DEFINE SERVER "Your Novel Server Name"
#DEFINE USERNAME "Your User ID"
#DEFINE PASSWORD "Your Password"
LOCAL lnCode, lnConnectionID, lnDrive
LOCAL lcServer
* Declare DLLS
SET PATH TO C:\Windows\System
DECLARE Integer NWCallsInit IN CalWin32 ;
Integer, Integer
DECLARE Integer NWAttachToFileServer IN CalWin32 ;
String cServer, Integer nScopeFlag, Integer @nConnectionID
DECLARE Integer NWGetConnectionHandle IN CalWin32 ;
String cServer, Integer, Integer @nConnectionID, Integer
DECLARE Integer NWLoginToFileServer IN CalWin32 ;
Integer nConnectionID, String cObjectName, Integer nObjectType, String cPassword
DECLARE Integer NWSetDriveBase IN CalWin32 ;
Integer nDrive, Integer nConnectionID, Integer nDirHandle, String cDir, Integer
DECLARE Integer NWGetDefaultConnectionID IN CalWin32 ;
Integer @nConnectionID
DECLARE Integer NWGetFileServerName IN CalWin32 ;
Integer nConnectionID, String @cServer
DECLARE Integer NWDeleteDriveBase IN CalWin32 ;
Integer nDrive, Integer
* Initialize NetWare Interface
lnCode = NWCallsInit(0, 0)
DO CheckError WITH (lnCode), "NWCallsInit"
* Default server
lnCode = NWGetDefaultConnectionID(@lnConnectionID)
DO CheckError WITH (lnCode), "NWGetDefaultConnectionID"
lcServer = SPACE(50)
lnCode = NWGetFileServerName(lnConnectionID, @lcServer)
DO CheckError WITH (lnCode), "NWGetFileServerName"
= MESSAGEBOX("Default server is " + ALLTRIM(lcServer))
* Log into server
lnCode = NWGetConnectionHandle(SERVER, 0, @lnConnectionID, 0)
IF lnCode != 0
lnCode = NWAttachToFileServer(SERVER, 0, @lnConnectionID)
IF lnCode != NWR_ALREADY_ATTACHED
DO CheckError WITH (lnCode), "NWAttachToFileServer"
ENDIF
ENDIF
lnCode = NWLoginToFileServer(lnConnectionID, USERNAME, OT_USER, PASSWORD)
DO CheckError WITH (lnCode), "NWLoginToFileServer"
* Map drive (Drive number is 1=A, 2=B, etc.)
lnDrive = ASC("H") - ASC("A") + 1 && Drive letter H
lnCode = NWDeleteDriveBase(lnDrive, 0)
DO CheckError WITH (lnCode), "NWDeleteDriveBase"
lnCode = NWSetDriveBase(lnDrive, lnConnectionID, 0, "SYS:", 0)
DO CheckError WITH (lnCode), "NWSetDriveBase"
RETURN
PROCEDURE CheckError
LPARAMETERS tnCode, tcFunction
IF tnCode != 0
= MESSAGEBOX(tcFunction + " returned an error of " + ALLTRIM(STR(tnCode)))
CANCEL
ENDIF
RETURN