| 1 | /*:VRX Main
|
|---|
| 2 | */
|
|---|
| 3 | /* Samba Logon utility for OS/2
|
|---|
| 4 | Copyright (C) 2007-2017 Herwig Bauernfeind for bww bitwise works GmbH.
|
|---|
| 5 |
|
|---|
| 6 | This program is free software: you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | /* Main
|
|---|
| 21 | */
|
|---|
| 22 | Main:
|
|---|
| 23 | /* Process the arguments.
|
|---|
| 24 | Get the parent window.
|
|---|
| 25 | */
|
|---|
| 26 | parse source . calledAs .
|
|---|
| 27 | parent = ""
|
|---|
| 28 | argCount = arg()
|
|---|
| 29 | argOff = 0
|
|---|
| 30 | if( calledAs \= "COMMAND" )then do
|
|---|
| 31 | if argCount >= 1 then do
|
|---|
| 32 | parent = arg(1)
|
|---|
| 33 | argCount = argCount - 1
|
|---|
| 34 | argOff = 1
|
|---|
| 35 | end
|
|---|
| 36 | end; else do
|
|---|
| 37 | call VROptions 'ImplicitNames'
|
|---|
| 38 | call VROptions 'NoEchoQuit'
|
|---|
| 39 | end
|
|---|
| 40 | InitArgs.0 = argCount
|
|---|
| 41 | if( argCount > 0 )then do i = 1 to argCount
|
|---|
| 42 | InitArgs.i = arg( i + argOff )
|
|---|
| 43 | end
|
|---|
| 44 | drop calledAs argCount argOff
|
|---|
| 45 |
|
|---|
| 46 | /* Load the windows
|
|---|
| 47 | */
|
|---|
| 48 | call VRInit
|
|---|
| 49 | parse source . . spec
|
|---|
| 50 | _VREPrimaryWindowPath = ,
|
|---|
| 51 | VRParseFileName( spec, "dpn" ) || ".VRW"
|
|---|
| 52 | _VREPrimaryWindow = ,
|
|---|
| 53 | VRLoad( parent, _VREPrimaryWindowPath )
|
|---|
| 54 | drop parent spec
|
|---|
| 55 | if( _VREPrimaryWindow == "" )then do
|
|---|
| 56 | call VRMessage "", "Cannot load window:" VRError(), ,
|
|---|
| 57 | "Error!"
|
|---|
| 58 | _VREReturnValue = 32000
|
|---|
| 59 | signal _VRELeaveMain
|
|---|
| 60 | end
|
|---|
| 61 |
|
|---|
| 62 | /* Process events
|
|---|
| 63 | */
|
|---|
| 64 | call Init
|
|---|
| 65 | signal on halt
|
|---|
| 66 | do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
|
|---|
| 67 | _VREEvent = VREvent()
|
|---|
| 68 | interpret _VREEvent
|
|---|
| 69 | end
|
|---|
| 70 | _VREHalt:
|
|---|
| 71 | _VREReturnValue = Fini()
|
|---|
| 72 | call VRDestroy _VREPrimaryWindow
|
|---|
| 73 | _VRELeaveMain:
|
|---|
| 74 | call VRFini
|
|---|
| 75 | exit _VREReturnValue
|
|---|
| 76 |
|
|---|
| 77 | VRLoadSecondary:
|
|---|
| 78 | __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
|
|---|
| 79 | if __vrlsWait then do
|
|---|
| 80 | call VRFlush
|
|---|
| 81 | end
|
|---|
| 82 | __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
|
|---|
| 83 | if __vrlsHWnd = '' then signal __vrlsDone
|
|---|
| 84 | if __vrlsWait \= 1 then signal __vrlsDone
|
|---|
| 85 | call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
|
|---|
| 86 | __vrlsTmp = __vrlsWindows.0
|
|---|
| 87 | if( DataType(__vrlsTmp) \= 'NUM' ) then do
|
|---|
| 88 | __vrlsTmp = 1
|
|---|
| 89 | end
|
|---|
| 90 | else do
|
|---|
| 91 | __vrlsTmp = __vrlsTmp + 1
|
|---|
| 92 | end
|
|---|
| 93 | __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
|
|---|
| 94 | __vrlsWindows.0 = __vrlsTmp
|
|---|
| 95 | do while( VRIsValidObject( VRWindow() ) = 1 )
|
|---|
| 96 | __vrlsEvent = VREvent()
|
|---|
| 97 | interpret __vrlsEvent
|
|---|
| 98 | end
|
|---|
| 99 | __vrlsTmp = __vrlsWindows.0
|
|---|
| 100 | __vrlsWindows.0 = __vrlsTmp - 1
|
|---|
| 101 | call VRWindow __vrlsWindows.__vrlsTmp
|
|---|
| 102 | __vrlsHWnd = ''
|
|---|
| 103 | __vrlsDone:
|
|---|
| 104 | return __vrlsHWnd
|
|---|
| 105 |
|
|---|
| 106 | /*:VRX __VXREXX____APPENDS__
|
|---|
| 107 | */
|
|---|
| 108 | __VXREXX____APPENDS__:
|
|---|
| 109 | /*
|
|---|
| 110 | #append U:\Develop\Samba\trunk\guitools\shared\usercredmem.vrs
|
|---|
| 111 | #append U:\Develop\Samba\trunk\guitools\shared\cltinit.vrs
|
|---|
| 112 | #append U:\Develop\Samba\trunk\guitools\shared\inittempdir.vrs
|
|---|
| 113 | #append U:\Develop\Samba\trunk\guitools\shared\rxrpclib.vrs
|
|---|
| 114 | #append U:\Develop\Samba\trunk\guitools\shared\masterpasswd.vrs
|
|---|
| 115 | #append U:\Develop\Samba\trunk\guitools\shared\nlv.vrs
|
|---|
| 116 | */
|
|---|
| 117 | return
|
|---|
| 118 | /*:VRX _ContainerInit
|
|---|
| 119 | */
|
|---|
| 120 | _ContainerInit:
|
|---|
| 121 | Status.StatusFH = VRMethod( "CN_STATUS", "AddField", "Icon", "Status" )
|
|---|
| 122 | Status.MessageFH = VRMethod( "CN_STATUS", "AddField", "String", "Message" )
|
|---|
| 123 | return
|
|---|
| 124 |
|
|---|
| 125 | /*:VRX _INIRead
|
|---|
| 126 | */
|
|---|
| 127 | _INIRead:
|
|---|
| 128 |
|
|---|
| 129 | return
|
|---|
| 130 |
|
|---|
| 131 | /*:VRX _INIWrite
|
|---|
| 132 | */
|
|---|
| 133 | _INIWrite:
|
|---|
| 134 |
|
|---|
| 135 | return
|
|---|
| 136 |
|
|---|
| 137 | /*:VRX _IsValidLocalUser
|
|---|
| 138 | */
|
|---|
| 139 | _IsValidLocalUser:
|
|---|
| 140 | LocalUser = arg(1)
|
|---|
| 141 | UserMatch = 0
|
|---|
| 142 | do I = 1 to username.0
|
|---|
| 143 | if translate(username.I) = translate(LocalUser) then do
|
|---|
| 144 | UserMatch = 1
|
|---|
| 145 | LocalPasswd = password.I
|
|---|
| 146 | leave
|
|---|
| 147 | end
|
|---|
| 148 | end
|
|---|
| 149 | return UserMatch
|
|---|
| 150 |
|
|---|
| 151 | /*:VRX _LoadOtherFuncs
|
|---|
| 152 | */
|
|---|
| 153 | _LoadOtherFuncs:
|
|---|
| 154 | IF options.!debug == 1 THEN say "_LoadotherFuncs() started"
|
|---|
| 155 | IF options.!debug == 1 THEN ok = VRRedirectStdIO("ON")
|
|---|
| 156 | ELSE ok = VRRedirectStdIO("OFF")
|
|---|
| 157 |
|
|---|
| 158 | /* what REXX script would be complete without this... */
|
|---|
| 159 | call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
|
|---|
| 160 | call SysLoadFuncs
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 | call RxFuncAdd 'RxuInit', 'RXU', 'RxuInit'
|
|---|
| 164 | call RxuInit
|
|---|
| 165 |
|
|---|
| 166 | call rxFuncAdd 'Crypt', 'RxCrypt', 'RxCrypt'
|
|---|
| 167 | IF options.!debug == 1 THEN say "_LoadotherFuncs() done"
|
|---|
| 168 | return
|
|---|
| 169 |
|
|---|
| 170 | /*:VRX _LogonLocal
|
|---|
| 171 | */
|
|---|
| 172 | _LogonLocal:
|
|---|
| 173 | ErrorStatus = 0
|
|---|
| 174 | IF options.!debug == 1 THEN say "_LogonLocal() started"
|
|---|
| 175 | if \_IsValidLocalUser(Credentials.!Username) then do
|
|---|
| 176 | ErrorStatus = 1
|
|---|
| 177 | Msg.Type = "E"
|
|---|
| 178 | Msg.Text = "Invalid local user - specify server to authenticate against!"
|
|---|
| 179 | call _ShowMsg
|
|---|
| 180 | end
|
|---|
| 181 | else do
|
|---|
| 182 | passtwo = Crypt(Credentials.!password , LocalPasswd )
|
|---|
| 183 | if LocalPasswd <> passtwo then do
|
|---|
| 184 | ErrorStatus = 1
|
|---|
| 185 | Msg.Text = "Invalid local password!"
|
|---|
| 186 | call _ShowMsg
|
|---|
| 187 | end
|
|---|
| 188 | else do
|
|---|
| 189 | ok = VRSet("DT_WELCOME","Caption", Credentials.!Username" authenticated locally!")
|
|---|
| 190 | StoreCreds = 1
|
|---|
| 191 | end
|
|---|
| 192 | end
|
|---|
| 193 | if _ucChkObj() & StoreCreds then do
|
|---|
| 194 | if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0
|
|---|
| 195 | then UserCred = '--user='Credentials.!username'%'Credentials.!password
|
|---|
| 196 | else UserCred = '--user='Credentials.!username'%%'Credentials.!password
|
|---|
| 197 | ok = _ucSetUc()
|
|---|
| 198 | end
|
|---|
| 199 | else do
|
|---|
| 200 | ErrorStatus = 1
|
|---|
| 201 | Msg.Text = "Credentials not stored!"
|
|---|
| 202 | call _ShowMsg
|
|---|
| 203 | end
|
|---|
| 204 | if ErrorStatus = 1 then do
|
|---|
| 205 | Msg.Type = "E"
|
|---|
| 206 | Msg.Text = "Errors during logon!"
|
|---|
| 207 | call _ShowMsg
|
|---|
| 208 | ok = VRSet("PB_Cancel","Visible", 1)
|
|---|
| 209 | end
|
|---|
| 210 | else ok = VRSet("TM_Quit","Enabled",1)
|
|---|
| 211 | IF options.!debug == 1 THEN say "_LogonLocal() done"
|
|---|
| 212 | return
|
|---|
| 213 |
|
|---|
| 214 | /*:VRX _LogonServer
|
|---|
| 215 | */
|
|---|
| 216 | _LogonServer:
|
|---|
| 217 | IF options.!debug == 1 THEN say "_LogonServer() started"
|
|---|
| 218 | ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username)
|
|---|
| 219 | LogonStatus = word(ok,1)
|
|---|
| 220 |
|
|---|
| 221 | if LogonStatus = "1" then Msg.Type ="I"
|
|---|
| 222 | else Msg.Type ="E"
|
|---|
| 223 | LogonWelcome = "Welcome" /* NLVGetMessage(x) */
|
|---|
| 224 | ok = VRSet("DT_WELCOME","Caption", LogonWelcome' 'rpc.queryuser.FULL_NAME)
|
|---|
| 225 |
|
|---|
| 226 | ok = SysFileDelete(samba.!msg)
|
|---|
| 227 | ErrorStatus = 0
|
|---|
| 228 | address cmd 'evfscli.exe attach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg
|
|---|
| 229 | attach_rc = rc
|
|---|
| 230 |
|
|---|
| 231 | do until lines(samba.!msg) = 0
|
|---|
| 232 | attachline = linein(samba.!msg)
|
|---|
| 233 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
|---|
| 234 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, attachline)
|
|---|
| 235 | call beautify attachline
|
|---|
| 236 | end
|
|---|
| 237 | ok = stream(samba.!msg,'c','close')
|
|---|
| 238 |
|
|---|
| 239 | /* \mountpoint ;workgroup=...;server=...;share=...;user=...;password=...;master=...;mastertype=...;memlen=...;logfile=...;loglevel=...;easupport=...) */
|
|---|
| 240 |
|
|---|
| 241 | parse var rpc.queryuser.PROFILE_PATH '\\'server'\'pshare'\'puser
|
|---|
| 242 |
|
|---|
| 243 | pshare = 'netlogon'
|
|---|
| 244 |
|
|---|
| 245 | /* EVFSCLI MOUNT type mountpoint resource {R|W} [F] */
|
|---|
| 246 | say 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W'
|
|---|
| 247 | address cmd 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W >'samba.!msg
|
|---|
| 248 | mount_rc = rc
|
|---|
| 249 | do until lines(samba.!msg) = 0
|
|---|
| 250 | mountline = linein(samba.!msg)
|
|---|
| 251 |
|
|---|
| 252 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
|---|
| 253 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
|
|---|
| 254 |
|
|---|
| 255 | call beautify mountline
|
|---|
| 256 | end
|
|---|
| 257 | ok = stream(samba.!msg,'c','close')
|
|---|
| 258 |
|
|---|
| 259 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
|---|
| 260 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Start logon script")
|
|---|
| 261 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Application")
|
|---|
| 262 |
|
|---|
| 263 | ok = Value('OS','ECS','OS2ENVIRONMENT')
|
|---|
| 264 | ok = Value("SERVER",Server,"OS2ENVIRONMENT")
|
|---|
| 265 | ok = Value("USER",Credentials.!Username,"OS2ENVIRONMENT")
|
|---|
| 266 | ok = Value("PASSWORD",Credentials.!password,"OS2ENVIRONMENT")
|
|---|
| 267 |
|
|---|
| 268 | address cmd rpc.queryuser.DIR_DRIVE'\'rpc.queryuser.LOGON_SCRIPT' >'samba.!msg
|
|---|
| 269 |
|
|---|
| 270 | do until lines(samba.!msg) = 0
|
|---|
| 271 | mountline = linein(samba.!msg)
|
|---|
| 272 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
|---|
| 273 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
|
|---|
| 274 | call beautify mountline
|
|---|
| 275 | end
|
|---|
| 276 | ok = stream(samba.!msg,'c','close')
|
|---|
| 277 |
|
|---|
| 278 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
|---|
| 279 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Logon script done.")
|
|---|
| 280 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Application")
|
|---|
| 281 |
|
|---|
| 282 | say 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE
|
|---|
| 283 | address cmd 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg
|
|---|
| 284 | do until lines(samba.!msg) = 0
|
|---|
| 285 | mountline = linein(samba.!msg)
|
|---|
| 286 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
|---|
| 287 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
|
|---|
| 288 | call beautify mountline
|
|---|
| 289 | end
|
|---|
| 290 | /* remove server and password from environment */
|
|---|
| 291 | ok = Value("SERVER","","OS2ENVIRONMENT")
|
|---|
| 292 | ok = value("PASSWORD","","OS2ENVIRONMENT")
|
|---|
| 293 | ok = stream(samba.!msg,'c','close')
|
|---|
| 294 | if ErrorStatus = 1 then do
|
|---|
| 295 | Msg.Type = "E"
|
|---|
| 296 | Msg.Text = "Errors during logon!"
|
|---|
| 297 | call _ShowMsg
|
|---|
| 298 | ok = VRSet("PB_Cancel","Visible", 1)
|
|---|
| 299 | end
|
|---|
| 300 | else ok = VRSet("TM_Quit","Enabled",1)
|
|---|
| 301 | IF options.!debug == 1 THEN say "_LogonServer() done"
|
|---|
| 302 | return
|
|---|
| 303 |
|
|---|
| 304 | beautify:
|
|---|
| 305 | bLine = translate(arg(1))
|
|---|
| 306 | select
|
|---|
| 307 | when pos("DRIVE LETTER",bLine) > 0 & pos("HAS BEEN CREATED",bLine) > 0 then do
|
|---|
| 308 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, icons.!drive)
|
|---|
| 309 | end
|
|---|
| 310 | when pos("RESOURCE HAS BEEN MOUNTED",bLine) > 0 then do
|
|---|
| 311 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, icons.!folder_open)
|
|---|
| 312 | end
|
|---|
| 313 | when pos("DRIVE LETTER",bLine) > 0 & pos("HAS BEEN DELETED",bLine) > 0 then do
|
|---|
| 314 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, icons.!drive_inactive)
|
|---|
| 315 | end
|
|---|
| 316 | when left(bLIne,3) = "EVC" | pos(" NOT ",bLine) > 0 | pos("ALREADY IN USE",bLine) > 0 then do
|
|---|
| 317 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Error")
|
|---|
| 318 | ErrorStatus = 1
|
|---|
| 319 | end
|
|---|
| 320 | otherwise nop /* ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.StatusFH, "Information") */
|
|---|
| 321 | end
|
|---|
| 322 | return
|
|---|
| 323 |
|
|---|
| 324 | /*:VRX _NLVSetup
|
|---|
| 325 | */
|
|---|
| 326 | _NLVSetup:
|
|---|
| 327 |
|
|---|
| 328 | return
|
|---|
| 329 |
|
|---|
| 330 | /*:VRX _ParseCommandLine
|
|---|
| 331 | */
|
|---|
| 332 | _ParseCommandLine:
|
|---|
| 333 | IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() started"
|
|---|
| 334 | CmdLine = VRGet("Application","Commandline")
|
|---|
| 335 | IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"'
|
|---|
| 336 | upCmdLine = translate(CmdLine)
|
|---|
| 337 |
|
|---|
| 338 | UserPos = 0
|
|---|
| 339 | UserPos = pos('--USER=',upCmdLine)
|
|---|
| 340 |
|
|---|
| 341 | if UserPos > 0 then do
|
|---|
| 342 | IF options.!debug == 1 THEN SAY " --USER switch detected"
|
|---|
| 343 | UserPasswd = translate(word(substr(CmdLine,UserPos+7,),1),'%','|')
|
|---|
| 344 | parse var UserPasswd Credentials.!Username '%' Credentials.!password
|
|---|
| 345 | end
|
|---|
| 346 | else do
|
|---|
| 347 | UserPos = pos('-U ',upCmdLine)
|
|---|
| 348 | If UserPos > 0 then do
|
|---|
| 349 | IF options.!debug == 1 THEN SAY " -U switch detected"
|
|---|
| 350 | UserPasswd = translate(word(substr(CmdLine,UserPos+3,),1),'%','|')
|
|---|
| 351 | parse var UserPasswd Credentials.!Username '%' Credentials.!password
|
|---|
| 352 | end
|
|---|
| 353 | end
|
|---|
| 354 |
|
|---|
| 355 | ServerPos = 0
|
|---|
| 356 | ServerPos = pos('--SERVER=',upCmdLine)
|
|---|
| 357 | Server = ""
|
|---|
| 358 |
|
|---|
| 359 | if ServerPos > 0 then do
|
|---|
| 360 | IF options.!debug == 1 THEN SAY " --SERVER switch detected"
|
|---|
| 361 | server = word(substr(CmdLine,ServerPos+9,),1)
|
|---|
| 362 | end
|
|---|
| 363 | else do
|
|---|
| 364 | ServerPos = pos('-S ',upCmdLine)
|
|---|
| 365 | If ServerPos > 0 then do
|
|---|
| 366 | IF options.!debug == 1 THEN SAY " -S switch detected"
|
|---|
| 367 | Server = word((substr(CmdLine,ServerPos+3,),1)
|
|---|
| 368 | end
|
|---|
| 369 | end
|
|---|
| 370 |
|
|---|
| 371 | if Credentials.!Username = "" then do
|
|---|
| 372 | IF options.!debug == 1 THEN say ' Reading username from envvar USER'
|
|---|
| 373 | Credentials.!Username = value("USER",,"OS2ENVIRONMENT")
|
|---|
| 374 | end
|
|---|
| 375 |
|
|---|
| 376 | IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"'
|
|---|
| 377 | IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"'
|
|---|
| 378 | IF options.!debug == 1 THEN say ' Server ="'Server'"'
|
|---|
| 379 | IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() done"
|
|---|
| 380 | return
|
|---|
| 381 |
|
|---|
| 382 | /*:VRX _ShowMsg
|
|---|
| 383 | */
|
|---|
| 384 | _ShowMsg:
|
|---|
| 385 | Buttons.1 = "OK" /* NLVGetMessage(2) */
|
|---|
| 386 | Buttons.0 = 1
|
|---|
| 387 | id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
|
|---|
| 388 | return
|
|---|
| 389 | /*:VRX _StemsInit
|
|---|
| 390 | */
|
|---|
| 391 | _StemsInit:
|
|---|
| 392 | if options.!debug == 1 then say time()' _StemsInit started'
|
|---|
| 393 |
|
|---|
| 394 | if options.!debug == 1 then say ' initializing msg. '
|
|---|
| 395 | msg.title = "Samba Logon"
|
|---|
| 396 |
|
|---|
| 397 | if options.!debug == 1 then say ' initializing credentials. '
|
|---|
| 398 | credentials. =""
|
|---|
| 399 | credentials.!username = ""
|
|---|
| 400 | credentials.!password = ""
|
|---|
| 401 |
|
|---|
| 402 | if options.!debug == 1 then say ' initializing icons. '
|
|---|
| 403 | icons.!bat = '#1:PMWP.DLL'
|
|---|
| 404 | icons.!cmd = '#2:PMWP.DLL'
|
|---|
| 405 | icons.!exe = '#3:PMWP.DLL'
|
|---|
| 406 | icons.!template = '#10:PMWP.DLL'
|
|---|
| 407 | icons.!drive = '#16:PMWP.DLL'
|
|---|
| 408 | icons.!defaultfile = '#24:PMWP.DLL'
|
|---|
| 409 | icons.!folder = '#26:PMWP.DLL'
|
|---|
| 410 | icons.!folder_open = '#34:PMWP.DLL'
|
|---|
| 411 | icons.!machine_awake = '#35:PMWP.DLL'
|
|---|
| 412 | icons.!machine_sleeping = '#61:PMWP.DLL'
|
|---|
| 413 | icons.!workgroup = '#62:PMWP.DLL'
|
|---|
| 414 | icons.!pdc = '#63:PMWP.DLL'
|
|---|
| 415 | icons.!active = '#64:PMWP.DLL'
|
|---|
| 416 | icons.!passive = '#68:PMWP.DLL'
|
|---|
| 417 | icons.!printer = '#65:PMWP.DLL'
|
|---|
| 418 | icons.!drive_inactive = '#70:PMWP.DLL'
|
|---|
| 419 |
|
|---|
| 420 | if options.!debug == 1 then say time()' _StemsInit done'
|
|---|
| 421 | return
|
|---|
| 422 |
|
|---|
| 423 | /*:VRX Fini
|
|---|
| 424 | */
|
|---|
| 425 | Fini:
|
|---|
| 426 | window = VRWindow()
|
|---|
| 427 | call VRSet window, "Visible", 0
|
|---|
| 428 | drop window
|
|---|
| 429 | return 0
|
|---|
| 430 |
|
|---|
| 431 | /*:VRX Halt
|
|---|
| 432 | */
|
|---|
| 433 | Halt:
|
|---|
| 434 | signal _VREHalt
|
|---|
| 435 | return
|
|---|
| 436 |
|
|---|
| 437 | /*:VRX Init
|
|---|
| 438 | */
|
|---|
| 439 | Init:
|
|---|
| 440 | window = VRWindow()
|
|---|
| 441 | call VRMethod window, "CenterWindow"
|
|---|
| 442 | call VRSet window, "Visible", 1
|
|---|
| 443 | call VRMethod window, "Activate"
|
|---|
| 444 | drop window
|
|---|
| 445 | return
|
|---|
| 446 |
|
|---|
| 447 | /*:VRX Main_Close
|
|---|
| 448 | */
|
|---|
| 449 | Main_Close:
|
|---|
| 450 | call Quit
|
|---|
| 451 | return
|
|---|
| 452 |
|
|---|
| 453 | /*:VRX Main_Create
|
|---|
| 454 | */
|
|---|
| 455 | Main_Create:
|
|---|
| 456 | options.!debug = 1
|
|---|
| 457 | call _LoadOtherFuncs
|
|---|
| 458 |
|
|---|
| 459 | call _INIRead
|
|---|
| 460 | call NLVSetup
|
|---|
| 461 | call _StemsInit
|
|---|
| 462 |
|
|---|
| 463 | call _InitTempDir
|
|---|
| 464 | call _CltInit
|
|---|
| 465 |
|
|---|
| 466 | call _ContainerInit
|
|---|
| 467 | call _NLVSetup
|
|---|
| 468 |
|
|---|
| 469 | ok = _ucInitObj()
|
|---|
| 470 |
|
|---|
| 471 | call _ParseCommandLine
|
|---|
| 472 |
|
|---|
| 473 | if Credentials.!user = "" | Credentials.!password = "" then do
|
|---|
| 474 | window = VRLoadSecondary( "SW_LOGIN", "W" )
|
|---|
| 475 | end
|
|---|
| 476 |
|
|---|
| 477 | IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"'
|
|---|
| 478 | IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"'
|
|---|
| 479 | IF options.!debug == 1 THEN say ' Server ="'Server'"'
|
|---|
| 480 |
|
|---|
| 481 | StoreCreds = 0
|
|---|
| 482 |
|
|---|
| 483 | call _MasterPasswdRead
|
|---|
| 484 |
|
|---|
| 485 | if Server = ""
|
|---|
| 486 | then call _LogonLocal /* Authenticate locally! */
|
|---|
| 487 | else call _LogonServer /* Authenticate against specified server */
|
|---|
| 488 |
|
|---|
| 489 | return
|
|---|
| 490 |
|
|---|
| 491 | /*:VRX Main_Resize
|
|---|
| 492 | */
|
|---|
| 493 | Main_Resize:
|
|---|
| 494 | ok = VRSet("CN_Status","Width", VRGet("Main", "WIdth")-144)
|
|---|
| 495 | ok = VRSet("CN_Status","Height",VRGet("Main", "Height")-144-434)
|
|---|
| 496 | return
|
|---|
| 497 |
|
|---|
| 498 | /*:VRX PB_Cancel_Click
|
|---|
| 499 | */
|
|---|
| 500 | PB_Cancel_Click:
|
|---|
| 501 | call quit
|
|---|
| 502 | return
|
|---|
| 503 |
|
|---|
| 504 | /*:VRX PB_LOGIN_CANCEL_Click
|
|---|
| 505 | */
|
|---|
| 506 | PB_LOGIN_CANCEL_Click:
|
|---|
| 507 | call SW_LOGIN_Close
|
|---|
| 508 | return 0
|
|---|
| 509 |
|
|---|
| 510 | /*:VRX PB_LOGIN_OK_Click
|
|---|
| 511 | */
|
|---|
| 512 | PB_LOGIN_OK_Click:
|
|---|
| 513 | Credentials.!username = VRGet("EF_USER1","Value")
|
|---|
| 514 | Credentials.!password = VRGet("EF_PASSWORD1","Value")
|
|---|
| 515 | UserCred = '--user='Credentials.!username'%'Credentials.!password
|
|---|
| 516 | call SW_LOGIN_Close
|
|---|
| 517 | return
|
|---|
| 518 |
|
|---|
| 519 | /*:VRX PB_Logon_Click
|
|---|
| 520 | */
|
|---|
| 521 | PB_Logon_Click:
|
|---|
| 522 | return
|
|---|
| 523 |
|
|---|
| 524 | /*:VRX PB_TEST1_Click
|
|---|
| 525 | */
|
|---|
| 526 | PB_TEST1_Click:
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 | /* ok = _rpcquerygroupmem(server, Credentials.!username, Credentials.!password,'0x201') */
|
|---|
| 530 | ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username)
|
|---|
| 531 |
|
|---|
| 532 | if ok = 1 then do
|
|---|
| 533 | ok = VRSetIni( "SmbLogon", c2x(server), c2x(Credentials.!username)'#'c2x(Credentials.!password), "SYSTEM" )
|
|---|
| 534 | end
|
|---|
| 535 | else do
|
|---|
| 536 | ok = VRDelIni( "SmbLogon", c2x(server),"SYSTEM")
|
|---|
| 537 | end
|
|---|
| 538 |
|
|---|
| 539 | /* ok = _rpcenumprinters(server, Credentials.!username, Credentials.!password) */
|
|---|
| 540 | /* ok = _rpcenumdomusers(server, Credentials.!username, Credentials.!password) */
|
|---|
| 541 | /* ok = _rpcsrvinfo(server, Credentials.!username, Credentials.!password) */
|
|---|
| 542 | /* ok = _rpcnetsharegetinfo(server, Credentials.!username, Credentials.!password,'data') */
|
|---|
| 543 | /* ok = _rpcnetshareenum(server, Credentials.!username, Credentials.!password) */
|
|---|
| 544 | return
|
|---|
| 545 |
|
|---|
| 546 | /*:VRX PB_TEST2_Click
|
|---|
| 547 | */
|
|---|
| 548 | PB_TEST2_Click:
|
|---|
| 549 | ucMem = '\SHAREMEM\INETXXX'
|
|---|
| 550 | ok = _ucChkObj()
|
|---|
| 551 | say ok
|
|---|
| 552 | ok = _ucChkUc()
|
|---|
| 553 | say ok
|
|---|
| 554 | if ok = 1 then do
|
|---|
| 555 | UserCred = _ucGetUc()
|
|---|
| 556 | say UserCred
|
|---|
| 557 | end
|
|---|
| 558 | else do
|
|---|
| 559 | ok = _ucSetUc()
|
|---|
| 560 | say ok
|
|---|
| 561 | end
|
|---|
| 562 | UserCred = _ucGetUc()
|
|---|
| 563 | say UserCred
|
|---|
| 564 | /* ok = _ucDelUc()
|
|---|
| 565 | ok = _ucChkUc()
|
|---|
| 566 | say ok */
|
|---|
| 567 |
|
|---|
| 568 | return
|
|---|
| 569 |
|
|---|
| 570 | /*:VRX Quit
|
|---|
| 571 | */
|
|---|
| 572 | Quit:
|
|---|
| 573 | call _SambaFinish
|
|---|
| 574 | window = VRWindow()
|
|---|
| 575 | call VRSet window, "Shutdown", 1
|
|---|
| 576 | drop window
|
|---|
| 577 | return
|
|---|
| 578 |
|
|---|
| 579 | /*:VRX SW_LOGIN_Close
|
|---|
| 580 | */
|
|---|
| 581 | SW_LOGIN_Close:
|
|---|
| 582 | call SW_LOGIN_Fini
|
|---|
| 583 | return
|
|---|
| 584 |
|
|---|
| 585 | /*:VRX SW_LOGIN_Create
|
|---|
| 586 | */
|
|---|
| 587 | SW_LOGIN_Create:
|
|---|
| 588 | call SW_LOGIN_Init
|
|---|
| 589 | CALL NLVSetText 'DT_USER1', 'Caption', 32
|
|---|
| 590 | CALL NLVSetText 'DT_PASSWORD1', 'Caption', 33
|
|---|
| 591 | CALL NLVSetText 'PB_LOGIN_OK', 'Caption', 2
|
|---|
| 592 | CALL NLVSetText 'PB_LOGIN_CANCEL','Caption', 3
|
|---|
| 593 |
|
|---|
| 594 | ok = VRSet("EF_User1","Value", Credentials.!Username)
|
|---|
| 595 | ok = VRSet("EF_PASSWORD1","Value",Credentials.!password)
|
|---|
| 596 | if Credentials.!Username = "" then ok = VRMethod("EF_User1", "SetFocus" )
|
|---|
| 597 | else ok = VRMethod("EF_PASSWORD1", "SetFocus" )
|
|---|
| 598 | return
|
|---|
| 599 |
|
|---|
| 600 | /*:VRX SW_LOGIN_Fini
|
|---|
| 601 | */
|
|---|
| 602 | SW_LOGIN_Fini:
|
|---|
| 603 | window = VRInfo( "Window" )
|
|---|
| 604 | call VRDestroy window
|
|---|
| 605 | drop window
|
|---|
| 606 | return
|
|---|
| 607 | /*:VRX SW_LOGIN_Init
|
|---|
| 608 | */
|
|---|
| 609 | SW_LOGIN_Init:
|
|---|
| 610 | window = VRInfo( "Object" )
|
|---|
| 611 | if( \VRIsChildOf( window, "Notebook" ) ) then do
|
|---|
| 612 | call VRMethod window, "CenterWindow"
|
|---|
| 613 | call VRSet window, "Visible", 1
|
|---|
| 614 | call VRMethod window, "Activate"
|
|---|
| 615 | end
|
|---|
| 616 | drop window
|
|---|
| 617 | return
|
|---|
| 618 |
|
|---|
| 619 | /*:VRX TM_Quit_Trigger
|
|---|
| 620 | */
|
|---|
| 621 | TM_Quit_Trigger:
|
|---|
| 622 | ok = VRRedirectStdio("OFF")
|
|---|
| 623 | call quit
|
|---|
| 624 | return
|
|---|
| 625 |
|
|---|