source: trunk/guitools/smblogon/smblogon.VRX@ 720

Last change on this file since 720 was 719, checked in by Herwig Bauernfeind, 13 years ago

GUI-Tools: smblogon initial commit

File size: 13.7 KB
Line 
1/*:VRX Main
2*/
3/* Main
4*/
5Main:
6/* Process the arguments.
7 Get the parent window.
8*/
9 parse source . calledAs .
10 parent = ""
11 argCount = arg()
12 argOff = 0
13 if( calledAs \= "COMMAND" )then do
14 if argCount >= 1 then do
15 parent = arg(1)
16 argCount = argCount - 1
17 argOff = 1
18 end
19 end; else do
20 call VROptions 'ImplicitNames'
21 call VROptions 'NoEchoQuit'
22 end
23 InitArgs.0 = argCount
24 if( argCount > 0 )then do i = 1 to argCount
25 InitArgs.i = arg( i + argOff )
26 end
27 drop calledAs argCount argOff
28
29/* Load the windows
30*/
31 call VRInit
32 parse source . . spec
33 _VREPrimaryWindowPath = ,
34 VRParseFileName( spec, "dpn" ) || ".VRW"
35 _VREPrimaryWindow = ,
36 VRLoad( parent, _VREPrimaryWindowPath )
37 drop parent spec
38 if( _VREPrimaryWindow == "" )then do
39 call VRMessage "", "Cannot load window:" VRError(), ,
40 "Error!"
41 _VREReturnValue = 32000
42 signal _VRELeaveMain
43 end
44
45/* Process events
46*/
47 call Init
48 signal on halt
49 do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
50 _VREEvent = VREvent()
51 interpret _VREEvent
52 end
53_VREHalt:
54 _VREReturnValue = Fini()
55 call VRDestroy _VREPrimaryWindow
56_VRELeaveMain:
57 call VRFini
58exit _VREReturnValue
59
60VRLoadSecondary:
61 __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
62 if __vrlsWait then do
63 call VRFlush
64 end
65 __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
66 if __vrlsHWnd = '' then signal __vrlsDone
67 if __vrlsWait \= 1 then signal __vrlsDone
68 call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
69 __vrlsTmp = __vrlsWindows.0
70 if( DataType(__vrlsTmp) \= 'NUM' ) then do
71 __vrlsTmp = 1
72 end
73 else do
74 __vrlsTmp = __vrlsTmp + 1
75 end
76 __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
77 __vrlsWindows.0 = __vrlsTmp
78 do while( VRIsValidObject( VRWindow() ) = 1 )
79 __vrlsEvent = VREvent()
80 interpret __vrlsEvent
81 end
82 __vrlsTmp = __vrlsWindows.0
83 __vrlsWindows.0 = __vrlsTmp - 1
84 call VRWindow __vrlsWindows.__vrlsTmp
85 __vrlsHWnd = ''
86__vrlsDone:
87return __vrlsHWnd
88
89/*:VRX __VXREXX____APPENDS__
90*/
91__VXREXX____APPENDS__:
92/*
93#append U:\Develop\Samba\trunk\guitools\shared\usercredmem.vrs
94#append U:\Develop\Samba\trunk\guitools\shared\cltinit.vrs
95#append U:\Develop\Samba\trunk\guitools\shared\inittempdir.vrs
96#append U:\Develop\Samba\trunk\guitools\shared\rxrpclib.vrs
97#append U:\Develop\Samba\trunk\guitools\shared\masterpasswd.vrs
98*/
99return
100/*:VRX _ContainerInit
101*/
102_ContainerInit:
103 Status.StatusFH = VRMethod( "CN_STATUS", "AddField", "Icon", "Status" )
104 Status.MessageFH = VRMethod( "CN_STATUS", "AddField", "String", "Message" )
105return
106
107/*:VRX _IsValidLocalUser
108*/
109_IsValidLocalUser:
110 LocalUser = arg(1)
111 UserMatch = 0
112 do I = 1 to username.0
113 if translate(username.I) = translate(LocalUser) then do
114 UserMatch = 1
115 LocalPasswd = password.I
116 leave
117 end
118 end
119return UserMatch
120
121/*:VRX _LoadOtherFuncs
122*/
123_LoadOtherFuncs:
124 IF options.!debug == 1 THEN say "_LoadotherFuncs() started"
125 IF options.!debug == 1 THEN ok = VRRedirectStdIO("ON")
126 ELSE ok = VRRedirectStdIO("OFF")
127
128 /* what REXX script would be complete without this... */
129 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
130 call SysLoadFuncs
131
132
133 call RxFuncAdd 'RxuInit', 'RXU', 'RxuInit'
134 call RxuInit
135
136 call rxFuncAdd 'Crypt', 'RxCrypt', 'RxCrypt'
137 IF options.!debug == 1 THEN say "_LoadotherFuncs() done"
138return
139
140/*:VRX _ParseCommandLine
141*/
142_ParseCommandLine:
143 IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() started"
144 CmdLine = VRGet("Application","Commandline")
145 IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"'
146 upCmdLine = translate(CmdLine)
147
148 UserPos = 0
149 UserPos = pos('--USER=',upCmdLine)
150
151 if UserPos > 0 then do
152 IF options.!debug == 1 THEN SAY " --USER switch detected"
153 UserPasswd = translate(word(substr(CmdLine,UserPos+7,),1),'%','|')
154 parse var UserPasswd Credentials.!Username '%' Credentials.!password
155 end
156 else do
157 UserPos = pos('-U ',upCmdLine)
158 If UserPos > 0 then do
159 IF options.!debug == 1 THEN SAY " -U switch detected"
160 UserPasswd = translate(word(substr(CmdLine,UserPos+3,),1),'%','|')
161 parse var UserPasswd Credentials.!Username '%' Credentials.!password
162 end
163 end
164
165 ServerPos = 0
166 ServerPos = pos('--SERVER=',upCmdLine)
167 Server = ""
168
169 if ServerPos > 0 then do
170 IF options.!debug == 1 THEN SAY " --SERVER switch detected"
171 server = word(substr(CmdLine,ServerPos+9,),1)
172 end
173 else do
174 ServerPos = pos('-S ',upCmdLine)
175 If ServerPos > 0 then do
176 IF options.!debug == 1 THEN SAY " -S switch detected"
177 Server = word((substr(CmdLine,ServerPos+3,),1)
178 end
179 end
180
181 if Credentials.!Username = "" then do
182 IF options.!debug == 1 THEN say ' Reading username from envvar USER'
183 Credentials.!Username = value("USER",,"OS2ENVIRONMENT")
184 end
185
186 IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"'
187 IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"'
188 IF options.!debug == 1 THEN say ' Server ="'Server'"'
189 IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() done"
190return
191
192/*:VRX _ShowMsg
193*/
194_ShowMsg:
195 Buttons.1 = "OK" /* NLVGetMessage(2) */
196 Buttons.0 = 1
197 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
198return
199/*:VRX Fini
200*/
201Fini:
202 window = VRWindow()
203 call VRSet window, "Visible", 0
204 drop window
205return 0
206
207/*:VRX Halt
208*/
209Halt:
210 signal _VREHalt
211return
212
213/*:VRX Init
214*/
215Init:
216 window = VRWindow()
217 call VRMethod window, "CenterWindow"
218 call VRSet window, "Visible", 1
219 call VRMethod window, "Activate"
220 drop window
221return
222
223/*:VRX Main_Close
224*/
225Main_Close:
226 call Quit
227return
228
229/*:VRX Main_Create
230*/
231Main_Create:
232 ok = VRRedirectStdio("ON")
233 options.!debug = 1
234
235 call _LoadOtherFuncs
236
237 call _InitTempDir
238 call _CltInit
239
240 call _ContainerInit
241
242 Credentials. =""
243
244 call _ParseCommandLine
245
246 if Credentials.!user = "" | Credentials.!password = "" then do
247 window = VRLoadSecondary( "SW_LOGIN", "W" )
248 end
249
250 IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"'
251 IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"'
252 IF options.!debug == 1 THEN say ' Server ="'Server'"'
253
254 StoreCreds = 0
255
256 call _MasterPasswdRead
257
258 if Server = "" then do /* NO Server specified - authenticate locally! */
259 if \_IsValidLocalUser(Credentials.!Username) then do
260 say "Invalid local user - specify server to authenticate against!"
261 end
262 else do
263 passtwo = Crypt(Credentials.!password , LocalPasswd )
264 if LocalPasswd <> passtwo then do
265 say "Invalid local password!"
266 end
267 else do
268 ok = VRSet("DT_WELCOME","Caption", Credentials.!Username" authenticated locally!")
269 StoreCreds = 1
270 end
271 end
272 if _ucChkObj() & StoreCreds then do
273 if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0
274 then UserCred = '--user='Credentials.!username'%'Credentials.!password
275 else UserCred = '--user='Credentials.!username'%%'Credentials.!password
276 ok = _ucSetUc()
277 end
278 end
279 else do /* Authenticate against specified server */
280 call PB_Logon_Click
281 end
282 ok = VRSet("TM_Quit","Enabled",1)
283return
284
285/*:VRX PB_Cancel_Click
286*/
287PB_Cancel_Click:
288 call quit
289return
290
291/*:VRX PB_LOGIN_CANCEL_Click
292*/
293PB_LOGIN_CANCEL_Click:
294 call SW_LOGIN_Close
295return 0
296
297/*:VRX PB_LOGIN_OK_Click
298*/
299PB_LOGIN_OK_Click:
300 Credentials.!username = VRGet("EF_USER1","Value")
301 Credentials.!password = VRGet("EF_PASSWORD1","Value")
302 UserCred = '--user='Credentials.!username'%'Credentials.!password
303 call SW_LOGIN_Close
304return
305
306/*:VRX PB_Logon_Click
307*/
308PB_Logon_Click:
309 ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username)
310 LogonStatus = word(ok,1)
311
312 if LogonStatus = "1" then Msg.Type ="I"
313 else Msg.Type ="E"
314 LogonWelcome = "Welcome" /* NLVGetMessage(x) */
315 ok = VRSet("DT_WELCOME","Caption", LogonWelcome' 'rpc.queryuser.FULL_NAME)
316
317 ok = SysFileDelete(samba.!msg)
318 address cmd 'evfscli.exe attach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg
319 attach_rc = rc
320
321 do until lines(samba.!msg) = 0
322 attachline = linein(samba.!msg)
323 rh = VRMethod( "CN_STATUS", "AddRecord")
324 ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, attachline)
325 end
326 ok = stream(samba.!msg,'c','close')
327
328 /* \mountpoint ;workgroup=...;server=...;share=...;user=...;password=...;master=...;mastertype=...;memlen=...;logfile=...;loglevel=...;easupport=...) */
329
330 parse var rpc.queryuser.PROFILE_PATH '\\'server'\'pshare'\'puser
331
332 pshare = 'netlogon'
333
334 /* EVFSCLI MOUNT type mountpoint resource {R|W} [F] */
335 say 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W'
336 address cmd 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W >'samba.!msg
337 mount_rc = rc
338 do until lines(samba.!msg) = 0
339 mountline = linein(samba.!msg)
340 rh = VRMethod( "CN_STATUS", "AddRecord")
341 ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
342 end
343 ok = stream(samba.!msg,'c','close')
344
345 rh = VRMethod( "CN_STATUS", "AddRecord")
346 ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Start logon script")
347
348 ok = Value('OS','ECS','OS2ENVIRONMENT')
349 address cmd rpc.queryuser.DIR_DRIVE'\'rpc.queryuser.LOGON_SCRIPT' >'samba.!msg
350 do until lines(samba.!msg) = 0
351 mountline = linein(samba.!msg)
352 rh = VRMethod( "CN_STATUS", "AddRecord")
353 ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
354 end
355 ok = stream(samba.!msg,'c','close')
356
357 rh = VRMethod( "CN_STATUS", "AddRecord")
358 ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Logon script done.")
359
360 say 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE
361 address cmd 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg
362 do until lines(samba.!msg) = 0
363 mountline = linein(samba.!msg)
364 rh = VRMethod( "CN_STATUS", "AddRecord")
365 ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
366 end
367 ok = stream(samba.!msg,'c','close')
368return
369
370/*:VRX PB_TEST1_Click
371*/
372PB_TEST1_Click:
373
374
375/* ok = _rpcquerygroupmem(server, Credentials.!username, Credentials.!password,'0x201') */
376ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username)
377
378if ok = 1 then do
379 ok = VRSetIni( "SmbLogon", c2x(server), c2x(Credentials.!username)'#'c2x(Credentials.!password), "SYSTEM" )
380end
381else do
382 ok = VRDelIni( "SmbLogon", c2x(server),"SYSTEM")
383end
384
385/* ok = _rpcenumprinters(server, Credentials.!username, Credentials.!password) */
386/* ok = _rpcenumdomusers(server, Credentials.!username, Credentials.!password) */
387/* ok = _rpcsrvinfo(server, Credentials.!username, Credentials.!password) */
388/* ok = _rpcnetsharegetinfo(server, Credentials.!username, Credentials.!password,'data') */
389/* ok = _rpcnetshareenum(server, Credentials.!username, Credentials.!password) */
390return
391
392/*:VRX PB_TEST2_Click
393*/
394PB_TEST2_Click:
395 ucMem = '\SHAREMEM\INETXXX'
396 ok = _ucChkObj()
397 say ok
398 ok = _ucChkUc()
399 say ok
400 if ok = 1 then do
401 UserCred = _ucGetUc()
402 say UserCred
403 end
404 else do
405 ok = _ucSetUc()
406 say ok
407 end
408 UserCred = _ucGetUc()
409 say UserCred
410/* ok = _ucDelUc()
411 ok = _ucChkUc()
412 say ok */
413
414return
415
416/*:VRX Quit
417*/
418Quit:
419 call _SambaFinish
420 window = VRWindow()
421 call VRSet window, "Shutdown", 1
422 drop window
423return
424
425/*:VRX SW_LOGIN_Close
426*/
427SW_LOGIN_Close:
428 call SW_LOGIN_Fini
429return
430
431/*:VRX SW_LOGIN_Create
432*/
433SW_LOGIN_Create:
434 call SW_LOGIN_Init
435/* CALL NLVSetText 'DT_USER1', 'Caption', 25
436 CALL NLVSetText 'DT_PASSWORD1', 'Caption', 26
437 CALL NLVSetText 'PB_LOGIN_OK', 'Caption', 2
438 CALL NLVSetText 'PB_LOGIN_CANCEL','Caption', 3 */
439
440 ok = VRSet("EF_User1","Value", Credentials.!Username)
441 ok = VRSet("EF_PASSWORD1","Value",Credentials.!password)
442return
443
444/*:VRX SW_LOGIN_Fini
445*/
446SW_LOGIN_Fini:
447 window = VRInfo( "Window" )
448 call VRDestroy window
449 drop window
450return
451/*:VRX SW_LOGIN_Init
452*/
453SW_LOGIN_Init:
454 window = VRInfo( "Object" )
455 if( \VRIsChildOf( window, "Notebook" ) ) then do
456 call VRMethod window, "CenterWindow"
457 call VRSet window, "Visible", 1
458 call VRMethod window, "Activate"
459 end
460 drop window
461return
462
463/*:VRX TM_Quit_Trigger
464*/
465TM_Quit_Trigger:
466 ok = VRRedirectStdio("OFF")
467 call quit
468return
469
Note: See TracBrowser for help on using the repository browser.