/*: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 */ return /*:VRX _ContainerInit */ _ContainerInit: Status.StatusFH = VRMethod( "CN_STATUS", "AddField", "Icon", "Status" ) Status.MessageFH = VRMethod( "CN_STATUS", "AddField", "String", "Message" ) 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 _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 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: ok = VRRedirectStdio("ON") options.!debug = 1 call _LoadOtherFuncs call _InitTempDir call _CltInit call _ContainerInit Credentials. ="" 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 do /* NO Server specified - authenticate locally! */ if \_IsValidLocalUser(Credentials.!Username) then do say "Invalid local user - specify server to authenticate against!" end else do passtwo = Crypt(Credentials.!password , LocalPasswd ) if LocalPasswd <> passtwo then do say "Invalid local password!" 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 end else do /* Authenticate against specified server */ call PB_Logon_Click end ok = VRSet("TM_Quit","Enabled",1) 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: 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) 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) 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) end ok = stream(samba.!msg,'c','close') rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Start logon script") ok = Value('OS','ECS','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) end ok = stream(samba.!msg,'c','close') rh = VRMethod( "CN_STATUS", "AddRecord") ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Logon script done.") 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) end ok = stream(samba.!msg,'c','close') 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', 25 CALL NLVSetText 'DT_PASSWORD1', 'Caption', 26 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) 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