/*:VRX Main */ /* Main */ Main: /* Process the arguments. Get the parent window. */ parse source . calledAs . parent = "" argCount = arg() argOff = 0 if( calledAs \= "COMMAND" )then do if argCount >= 1 then do parent = arg(1) argCount = argCount - 1 argOff = 1 end end; else do call VROptions 'ImplicitNames' call VROptions 'NoEchoQuit' end InitArgs.0 = argCount if( argCount > 0 )then do i = 1 to argCount InitArgs.i = arg( i + argOff ) end drop calledAs argCount argOff /* Load the windows */ call VRInit parse source . . spec _VREPrimaryWindowPath = , VRParseFileName( spec, "dpn" ) || ".VRW" _VREPrimaryWindow = , VRLoad( parent, _VREPrimaryWindowPath ) drop parent spec if( _VREPrimaryWindow == "" )then do call VRMessage "", "Cannot load window:" VRError(), , "Error!" _VREReturnValue = 32000 signal _VRELeaveMain end /* Process events */ call Init signal on halt do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) ) _VREEvent = VREvent() interpret _VREEvent end _VREHalt: _VREReturnValue = Fini() call VRDestroy _VREPrimaryWindow _VRELeaveMain: call VRFini exit _VREReturnValue VRLoadSecondary: __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 ) if __vrlsWait then do call VRFlush end __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) ) if __vrlsHWnd = '' then signal __vrlsDone if __vrlsWait \= 1 then signal __vrlsDone call VRSet __vrlsHWnd, 'WindowMode', 'Modal' __vrlsTmp = __vrlsWindows.0 if( DataType(__vrlsTmp) \= 'NUM' ) then do __vrlsTmp = 1 end else do __vrlsTmp = __vrlsTmp + 1 end __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd ) __vrlsWindows.0 = __vrlsTmp do while( VRIsValidObject( VRWindow() ) = 1 ) __vrlsEvent = VREvent() interpret __vrlsEvent end __vrlsTmp = __vrlsWindows.0 __vrlsWindows.0 = __vrlsTmp - 1 call VRWindow __vrlsWindows.__vrlsTmp __vrlsHWnd = '' __vrlsDone: return __vrlsHWnd /*:VRX __VXREXX____APPENDS__ */ __VXREXX____APPENDS__: /* #append U:\Develop\Samba\trunk\guitools\shared\usercredmem.vrs #append U:\Develop\Samba\trunk\guitools\shared\cltinit.vrs #append U:\Develop\Samba\trunk\guitools\shared\inittempdir.vrs #append U:\Develop\Samba\trunk\guitools\shared\rxrpclib.vrs #append U:\Develop\Samba\trunk\guitools\shared\masterpasswd.vrs #append U:\Develop\Samba\trunk\guitools\shared\nlv.vrs */ return /*:VRX _ContainerInit */ _ContainerInit: Status.StatusFH = VRMethod( "CN_STATUS", "AddField", "Icon", "Status" ) Status.MessageFH = VRMethod( "CN_STATUS", "AddField", "String", "Message" ) return /*:VRX _INIRead */ _INIRead: return /*:VRX _INIWrite */ _INIWrite: return /*:VRX _IsValidLocalUser */ _IsValidLocalUser: LocalUser = arg(1) UserMatch = 0 do I = 1 to username.0 if translate(username.I) = translate(LocalUser) then do UserMatch = 1 LocalPasswd = password.I leave end end return UserMatch /*:VRX _LoadOtherFuncs */ _LoadOtherFuncs: IF options.!debug == 1 THEN say "_LoadotherFuncs() started" IF options.!debug == 1 THEN ok = VRRedirectStdIO("ON") ELSE ok = VRRedirectStdIO("OFF") /* what REXX script would be complete without this... */ call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs call RxFuncAdd 'RxuInit', 'RXU', 'RxuInit' call RxuInit call rxFuncAdd 'Crypt', 'RxCrypt', 'RxCrypt' IF options.!debug == 1 THEN say "_LoadotherFuncs() done" return /*:VRX _LogonLocal */ _LogonLocal: ErrorStatus = 0 IF options.!debug == 1 THEN say "_LogonLocal() started" if \_IsValidLocalUser(Credentials.!Username) then do ErrorStatus = 1 Msg.Type = "E" Msg.Text = "Invalid local user - specify server to authenticate against!" call _ShowMsg end else do passtwo = Crypt(Credentials.!password , LocalPasswd ) if LocalPasswd <> passtwo then do ErrorStatus = 1 Msg.Text = "Invalid local password!" call _ShowMsg end else do ok = VRSet("DT_WELCOME","Caption", Credentials.!Username" authenticated locally!") StoreCreds = 1 end end if _ucChkObj() & StoreCreds then do if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0 then UserCred = '--user='Credentials.!username'%'Credentials.!password else UserCred = '--user='Credentials.!username'%%'Credentials.!password ok = _ucSetUc() end else do ErrorStatus = 1 Msg.Text = "Credentials not stored!" call _ShowMsg end if ErrorStatus = 1 then do Msg.Type = "E" Msg.Text = "Errors during logon!" call _ShowMsg ok = VRSet("PB_Cancel","Visible", 1) end else ok = VRSet("TM_Quit","Enabled",1) IF options.!debug == 1 THEN say "_LogonLocal() done" return /*:VRX _LogonServer */ _LogonServer: IF options.!debug == 1 THEN say "_LogonServer() started" ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username) LogonStatus = word(ok,1) if LogonStatus = "1" then Msg.Type ="I" else Msg.Type ="E" LogonWelcome = "Welcome" /* NLVGetMessage(x) */ ok = VRSet("DT_WELCOME","Caption", LogonWelcome' 'rpc.queryuser.FULL_NAME) ok = SysFileDelete(samba.!msg) ErrorStatus = 0 address cmd 'evfscli.exe attach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg attach_rc = rc do until lines(samba.!msg) = 0 attachline = linein(samba.!msg) rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, attachline) call beautify attachline end ok = stream(samba.!msg,'c','close') /* \mountpoint ;workgroup=...;server=...;share=...;user=...;password=...;master=...;mastertype=...;memlen=...;logfile=...;loglevel=...;easupport=...) */ parse var rpc.queryuser.PROFILE_PATH '\\'server'\'pshare'\'puser pshare = 'netlogon' /* EVFSCLI MOUNT type mountpoint resource {R|W} [F] */ say 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W' address cmd 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W >'samba.!msg mount_rc = rc do until lines(samba.!msg) = 0 mountline = linein(samba.!msg) rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline) call beautify mountline end ok = stream(samba.!msg,'c','close') rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Start logon script") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Application") ok = Value('OS','ECS','OS2ENVIRONMENT') ok = Value("SERVER",Server,"OS2ENVIRONMENT") ok = Value("USER",Credentials.!Username,"OS2ENVIRONMENT") ok = Value("PASSWORD",Credentials.!password,"OS2ENVIRONMENT") address cmd rpc.queryuser.DIR_DRIVE'\'rpc.queryuser.LOGON_SCRIPT' >'samba.!msg do until lines(samba.!msg) = 0 mountline = linein(samba.!msg) rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline) call beautify mountline end ok = stream(samba.!msg,'c','close') rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Logon script done.") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Application") say 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE address cmd 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg do until lines(samba.!msg) = 0 mountline = linein(samba.!msg) rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline) call beautify mountline end /* remove server and password from environment */ ok = Value("SERVER","","OS2ENVIRONMENT") ok = value("PASSWORD","","OS2ENVIRONMENT") ok = stream(samba.!msg,'c','close') if ErrorStatus = 1 then do Msg.Type = "E" Msg.Text = "Errors during logon!" call _ShowMsg ok = VRSet("PB_Cancel","Visible", 1) end else ok = VRSet("TM_Quit","Enabled",1) IF options.!debug == 1 THEN say "_LogonServer() done" return beautify: bLine = translate(arg(1)) select when pos("DRIVE LETTER",bLine) > 0 & pos("HAS BEEN CREATED",bLine) > 0 then do ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, icons.!drive) end when pos("RESOURCE HAS BEEN MOUNTED",bLine) > 0 then do ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, icons.!folder_open) end when pos("DRIVE LETTER",bLine) > 0 & pos("HAS BEEN DELETED",bLine) > 0 then do ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, icons.!drive_inactive) end when left(bLIne,3) = "EVC" | pos(" NOT ",bLine) > 0 | pos("ALREADY IN USE",bLine) > 0 then do ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Error") ErrorStatus = 1 end otherwise nop /* ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Information") */ end return /*:VRX _NLVSetup */ _NLVSetup: return /*:VRX _ParseCommandLine */ _ParseCommandLine: IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() started" CmdLine = VRGet("Application","Commandline") IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"' upCmdLine = translate(CmdLine) UserPos = 0 UserPos = pos('--USER=',upCmdLine) if UserPos > 0 then do IF options.!debug == 1 THEN SAY " --USER switch detected" UserPasswd = translate(word(substr(CmdLine,UserPos+7,),1),'%','|') parse var UserPasswd Credentials.!Username '%' Credentials.!password end else do UserPos = pos('-U ',upCmdLine) If UserPos > 0 then do IF options.!debug == 1 THEN SAY " -U switch detected" UserPasswd = translate(word(substr(CmdLine,UserPos+3,),1),'%','|') parse var UserPasswd Credentials.!Username '%' Credentials.!password end end ServerPos = 0 ServerPos = pos('--SERVER=',upCmdLine) Server = "" if ServerPos > 0 then do IF options.!debug == 1 THEN SAY " --SERVER switch detected" server = word(substr(CmdLine,ServerPos+9,),1) end else do ServerPos = pos('-S ',upCmdLine) If ServerPos > 0 then do IF options.!debug == 1 THEN SAY " -S switch detected" Server = word((substr(CmdLine,ServerPos+3,),1) end end if Credentials.!Username = "" then do IF options.!debug == 1 THEN say ' Reading username from envvar USER' Credentials.!Username = value("USER",,"OS2ENVIRONMENT") end IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"' IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"' IF options.!debug == 1 THEN say ' Server ="'Server'"' IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() done" return /*:VRX _ShowMsg */ _ShowMsg: Buttons.1 = "OK" /* NLVGetMessage(2) */ Buttons.0 = 1 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 ) return /*:VRX _StemsInit */ _StemsInit: if options.!debug == 1 then say time()' _StemsInit started' if options.!debug == 1 then say ' initializing msg. ' msg.title = "Samba Logon" if options.!debug == 1 then say ' initializing credentials. ' credentials. ="" credentials.!username = "" credentials.!password = "" if options.!debug == 1 then say ' initializing icons. ' icons.!bat = '#1:PMWP.DLL' icons.!cmd = '#2:PMWP.DLL' icons.!exe = '#3:PMWP.DLL' icons.!template = '#10:PMWP.DLL' icons.!drive = '#16:PMWP.DLL' icons.!defaultfile = '#24:PMWP.DLL' icons.!folder = '#26:PMWP.DLL' icons.!folder_open = '#34:PMWP.DLL' icons.!machine_awake = '#35:PMWP.DLL' icons.!machine_sleeping = '#61:PMWP.DLL' icons.!workgroup = '#62:PMWP.DLL' icons.!pdc = '#63:PMWP.DLL' icons.!active = '#64:PMWP.DLL' icons.!passive = '#68:PMWP.DLL' icons.!printer = '#65:PMWP.DLL' icons.!drive_inactive = '#70:PMWP.DLL' if options.!debug == 1 then say time()' _StemsInit done' return /*:VRX Fini */ Fini: window = VRWindow() call VRSet window, "Visible", 0 drop window return 0 /*:VRX Halt */ Halt: signal _VREHalt return /*:VRX Init */ Init: window = VRWindow() call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" drop window return /*:VRX Main_Close */ Main_Close: call Quit return /*:VRX Main_Create */ Main_Create: options.!debug = 1 call _LoadOtherFuncs call _INIRead call NLVSetup call _StemsInit call _InitTempDir call _CltInit call _ContainerInit call _NLVSetup ok = _ucInitObj() call _ParseCommandLine if Credentials.!user = "" | Credentials.!password = "" then do window = VRLoadSecondary( "SW_LOGIN", "W" ) end IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"' IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"' IF options.!debug == 1 THEN say ' Server ="'Server'"' StoreCreds = 0 call _MasterPasswdRead if Server = "" then call _LogonLocal /* Authenticate locally! */ else call _LogonServer /* Authenticate against specified server */ return /*:VRX Main_Resize */ Main_Resize: ok = VRSet("CN_Status","Width", VRGet("Main", "WIdth")-144) ok = VRSet("CN_Status","Height",VRGet("Main", "Height")-144-434) return /*:VRX PB_Cancel_Click */ PB_Cancel_Click: call quit return /*:VRX PB_LOGIN_CANCEL_Click */ PB_LOGIN_CANCEL_Click: call SW_LOGIN_Close return 0 /*:VRX PB_LOGIN_OK_Click */ PB_LOGIN_OK_Click: Credentials.!username = VRGet("EF_USER1","Value") Credentials.!password = VRGet("EF_PASSWORD1","Value") UserCred = '--user='Credentials.!username'%'Credentials.!password call SW_LOGIN_Close return /*:VRX PB_Logon_Click */ PB_Logon_Click: return /*:VRX PB_TEST1_Click */ PB_TEST1_Click: /* ok = _rpcquerygroupmem(server, Credentials.!username, Credentials.!password,'0x201') */ ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username) if ok = 1 then do ok = VRSetIni( "SmbLogon", c2x(server), c2x(Credentials.!username)'#'c2x(Credentials.!password), "SYSTEM" ) end else do ok = VRDelIni( "SmbLogon", c2x(server),"SYSTEM") end /* ok = _rpcenumprinters(server, Credentials.!username, Credentials.!password) */ /* ok = _rpcenumdomusers(server, Credentials.!username, Credentials.!password) */ /* ok = _rpcsrvinfo(server, Credentials.!username, Credentials.!password) */ /* ok = _rpcnetsharegetinfo(server, Credentials.!username, Credentials.!password,'data') */ /* ok = _rpcnetshareenum(server, Credentials.!username, Credentials.!password) */ return /*:VRX PB_TEST2_Click */ PB_TEST2_Click: ucMem = '\SHAREMEM\INETXXX' ok = _ucChkObj() say ok ok = _ucChkUc() say ok if ok = 1 then do UserCred = _ucGetUc() say UserCred end else do ok = _ucSetUc() say ok end UserCred = _ucGetUc() say UserCred /* ok = _ucDelUc() ok = _ucChkUc() say ok */ return /*:VRX Quit */ Quit: call _SambaFinish window = VRWindow() call VRSet window, "Shutdown", 1 drop window return /*:VRX SW_LOGIN_Close */ SW_LOGIN_Close: call SW_LOGIN_Fini return /*:VRX SW_LOGIN_Create */ SW_LOGIN_Create: call SW_LOGIN_Init CALL NLVSetText 'DT_USER1', 'Caption', 32 CALL NLVSetText 'DT_PASSWORD1', 'Caption', 33 CALL NLVSetText 'PB_LOGIN_OK', 'Caption', 2 CALL NLVSetText 'PB_LOGIN_CANCEL','Caption', 3 ok = VRSet("EF_User1","Value", Credentials.!Username) ok = VRSet("EF_PASSWORD1","Value",Credentials.!password) if Credentials.!Username = "" then ok = VRMethod("EF_User1", "SetFocus" ) else ok = VRMethod("EF_PASSWORD1", "SetFocus" ) return /*:VRX SW_LOGIN_Fini */ SW_LOGIN_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_LOGIN_Init */ SW_LOGIN_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX TM_Quit_Trigger */ TM_Quit_Trigger: ok = VRRedirectStdio("OFF") call quit return