1 | /*:VRX Main
|
---|
2 | */
|
---|
3 | /* Main
|
---|
4 | */
|
---|
5 | Main:
|
---|
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
|
---|
58 | exit _VREReturnValue
|
---|
59 |
|
---|
60 | VRLoadSecondary:
|
---|
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:
|
---|
87 | return __vrlsHWnd
|
---|
88 |
|
---|
89 | /*:VRX __VXREXX____APPENDS__
|
---|
90 | */
|
---|
91 | __VXREXX____APPENDS__:
|
---|
92 | /*
|
---|
93 | #append U:\Develop\Samba\guitools-2.0\shared\cltinit.vrs
|
---|
94 | #append U:\Develop\Samba\guitools-2.0\shared\inittempdir.vrs
|
---|
95 | */
|
---|
96 | return
|
---|
97 | /*:VRX _ContainerInit
|
---|
98 | */
|
---|
99 | _ContainerInit:
|
---|
100 | Status.StatusFH = VRMethod( "CN_STATUS", "AddField", "Icon", "Status" )
|
---|
101 | Status.MessageFH = VRMethod( "CN_STATUS", "AddField", "String", "Message" )
|
---|
102 | return
|
---|
103 |
|
---|
104 | /*:VRX _ParseCommandLine
|
---|
105 | */
|
---|
106 | _ParseCommandLine:
|
---|
107 | IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() started"
|
---|
108 | CmdLine = VRGet("Application","Commandline")
|
---|
109 | IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"'
|
---|
110 | upCmdLine = translate(CmdLine)
|
---|
111 |
|
---|
112 | UserPos = 0
|
---|
113 | UserPos = pos('--USER=',upCmdLine)
|
---|
114 |
|
---|
115 | if UserPos > 0 then do
|
---|
116 | IF options.!debug == 1 THEN SAY " --USER switch detected"
|
---|
117 | UserPasswd = translate(word(substr(CmdLine,UserPos+7,),1),'%','|')
|
---|
118 | parse var UserPasswd Credentials.!Username '%' Credentials.!password
|
---|
119 | end
|
---|
120 | else do
|
---|
121 | UserPos = pos('-U ',upCmdLine)
|
---|
122 | If UserPos > 0 then do
|
---|
123 | IF options.!debug == 1 THEN SAY " -U switch detected"
|
---|
124 | UserPasswd = translate(word(substr(CmdLine,UserPos+3,),1),'%','|')
|
---|
125 | parse var UserPasswd Credentials.!Username '%' Credentials.!password
|
---|
126 | end
|
---|
127 | end
|
---|
128 |
|
---|
129 | ServerPos = 0
|
---|
130 | ServerPos = pos('--SERVER=',upCmdLine)
|
---|
131 | Server = ""
|
---|
132 |
|
---|
133 | if ServerPos > 0 then do
|
---|
134 | IF options.!debug == 1 THEN SAY " --SERVER switch detected"
|
---|
135 | server = word(substr(CmdLine,ServerPos+9,),1)
|
---|
136 | end
|
---|
137 | else do
|
---|
138 | ServerPos = pos('-S ',upCmdLine)
|
---|
139 | If ServerPos > 0 then do
|
---|
140 | IF options.!debug == 1 THEN SAY " -S switch detected"
|
---|
141 | Server = word((substr(CmdLine,ServerPos+3,),1)
|
---|
142 | end
|
---|
143 | end
|
---|
144 |
|
---|
145 | if Credentials.!Username = "" then do
|
---|
146 | IF options.!debug == 1 THEN say ' Reading username from envvar USER'
|
---|
147 | Credentials.!Username = value("USER",,"OS2ENVIRONMENT")
|
---|
148 | end
|
---|
149 |
|
---|
150 | IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"'
|
---|
151 | IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"'
|
---|
152 | IF options.!debug == 1 THEN say ' Server ="'Server'"'
|
---|
153 | IF options.!debug == 1 THEN SAY time()" _ParseCommandLine() done"
|
---|
154 | return
|
---|
155 |
|
---|
156 | /*:VRX _rpcenumdomgroups
|
---|
157 | */
|
---|
158 | _rpcenumdomgroups: procedure expose rpc. samba. options.
|
---|
159 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomgroups() started"
|
---|
160 | server = arg(1)
|
---|
161 | username = arg(2)
|
---|
162 | password = arg(3)
|
---|
163 |
|
---|
164 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomgroups"'
|
---|
165 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomgroups" >'samba.!msg
|
---|
166 |
|
---|
167 | rpc.enumdomgroups. = ""
|
---|
168 |
|
---|
169 | Failure = 0
|
---|
170 |
|
---|
171 | count = 0
|
---|
172 | do until lines(samba.!msg) = 0
|
---|
173 | rpcline = linein(samba.!msg)
|
---|
174 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
175 |
|
---|
176 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
177 | Failure = 1
|
---|
178 | leave
|
---|
179 | end
|
---|
180 | parse var rpcline 'group:['tuser'] rid:['trid']'
|
---|
181 |
|
---|
182 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
183 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
184 | count = count + 1
|
---|
185 |
|
---|
186 | dyn = 'rpc.enumdomgroups.'count'.GROUP = "'Tuser'"'
|
---|
187 | say " "dyn
|
---|
188 | interpret dyn
|
---|
189 |
|
---|
190 | dyn = 'rpc.enumdomgroups.'count'.RID = "'Trid'"'
|
---|
191 | say " "dyn
|
---|
192 | interpret dyn
|
---|
193 |
|
---|
194 | end
|
---|
195 | ok = stream(samba.!msg,'c','close')
|
---|
196 | ok = SysFileDelete(samba.!msg)
|
---|
197 | rpc.enumdomgroups.0 = count
|
---|
198 |
|
---|
199 | if Failure = 0 then do
|
---|
200 | retval = 1
|
---|
201 | rpc.enumdomgroups.LOGONSTATUS="OK"
|
---|
202 | end
|
---|
203 | else do
|
---|
204 | retval = 0
|
---|
205 | rpc.enumdomgroups.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
206 | end
|
---|
207 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomgroups() done, "retval" "rpc.enumdomgroups.LOGONSTATUS
|
---|
208 | return retval
|
---|
209 | /*:VRX _rpcenumdomusers
|
---|
210 | */
|
---|
211 | _rpcenumdomusers: procedure expose rpc. samba. options.
|
---|
212 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomusers() started"
|
---|
213 | server = arg(1)
|
---|
214 | username = arg(2)
|
---|
215 | password = arg(3)
|
---|
216 |
|
---|
217 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomusers"'
|
---|
218 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumdomusers" >'samba.!msg
|
---|
219 |
|
---|
220 | rpc.enumdomusers. = ""
|
---|
221 |
|
---|
222 | Failure = 0
|
---|
223 |
|
---|
224 | count = 0
|
---|
225 | do until lines(samba.!msg) = 0
|
---|
226 | rpcline = linein(samba.!msg)
|
---|
227 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
228 |
|
---|
229 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
230 | Failure = 1
|
---|
231 | leave
|
---|
232 | end
|
---|
233 | parse var rpcline 'user:['tuser'] rid:['trid']'
|
---|
234 |
|
---|
235 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
236 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
237 | count = count + 1
|
---|
238 |
|
---|
239 | dyn = 'rpc.enumdomusers.'count'.USER = "'Tuser'"'
|
---|
240 | say " "dyn
|
---|
241 | interpret dyn
|
---|
242 |
|
---|
243 | dyn = 'rpc.enumdomusers.'count'.RID = "'Trid'"'
|
---|
244 | say " "dyn
|
---|
245 | interpret dyn
|
---|
246 |
|
---|
247 | end
|
---|
248 | ok = stream(samba.!msg,'c','close')
|
---|
249 | ok = SysFileDelete(samba.!msg)
|
---|
250 | rpc.enumdomusers.0 = count
|
---|
251 |
|
---|
252 | if Failure = 0 then do
|
---|
253 | retval = 1
|
---|
254 | rpc.enumdomusers.LOGONSTATUS="OK"
|
---|
255 | end
|
---|
256 | else do
|
---|
257 | retval = 0
|
---|
258 | rpc.enumdomusers.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
259 | end
|
---|
260 | IF options.!debug == 1 THEN SAY time()" _rpcenumdomusers() done, "retval" "rpc.enumdomusers.LOGONSTATUS
|
---|
261 | return retval
|
---|
262 |
|
---|
263 | /*:VRX _rpcenumprinters
|
---|
264 | */
|
---|
265 | _rpcenumprinters: procedure expose rpc. samba. options.
|
---|
266 | IF options.!debug == 1 THEN SAY time()" _rpcenumprinters() started"
|
---|
267 | server = arg(1)
|
---|
268 | username = arg(2)
|
---|
269 | password = arg(3)
|
---|
270 |
|
---|
271 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumprinters"'
|
---|
272 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="enumprinters" >'samba.!msg
|
---|
273 |
|
---|
274 | rpc.enumprinters. = ""
|
---|
275 |
|
---|
276 | Failure = 0
|
---|
277 |
|
---|
278 | count = 0
|
---|
279 | do until lines(samba.!msg) = 0
|
---|
280 | rpcline = linein(samba.!msg)
|
---|
281 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
282 |
|
---|
283 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
284 | Failure = 1
|
---|
285 | leave
|
---|
286 | end
|
---|
287 | parse var rpcline token ':[' tvalue']' .
|
---|
288 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
289 | if Token = "FLAGS" then count = count + 1
|
---|
290 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
291 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
---|
292 | dyn = 'rpc.enumprinters.'count'.'Token' = "'Tvalue'"'
|
---|
293 | say " "dyn
|
---|
294 | interpret dyn
|
---|
295 | end
|
---|
296 | end
|
---|
297 | ok = stream(samba.!msg,'c','close')
|
---|
298 | ok = SysFileDelete(samba.!msg)
|
---|
299 | rpc.enumprinters.0 = count
|
---|
300 |
|
---|
301 | if Failure = 0 then do
|
---|
302 | retval = 1
|
---|
303 | rpc.enumprinters.LOGONSTATUS="OK"
|
---|
304 | end
|
---|
305 | else do
|
---|
306 | retval = 0
|
---|
307 | rpc.enumprinters.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
308 | end
|
---|
309 | IF options.!debug == 1 THEN SAY time()" _rpcenumprinters() done, "retval" "rpc.enumprinters.LOGONSTATUS
|
---|
310 | return retval
|
---|
311 | /*:VRX _rpcnetshareenum
|
---|
312 | */
|
---|
313 | _rpcnetshareenum: procedure expose rpc. samba. options.
|
---|
314 | IF options.!debug == 1 THEN SAY time()" _rpcnetshareenum() started"
|
---|
315 | server = arg(1)
|
---|
316 | username = arg(2)
|
---|
317 | password = arg(3)
|
---|
318 |
|
---|
319 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="netshareenum"'
|
---|
320 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="netshareenum" >'samba.!msg
|
---|
321 |
|
---|
322 | rpc.netshareenum. = ""
|
---|
323 |
|
---|
324 | Failure = 0
|
---|
325 |
|
---|
326 | count = 0
|
---|
327 | do until lines(samba.!msg) = 0
|
---|
328 | rpcline = linein(samba.!msg)
|
---|
329 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
330 |
|
---|
331 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
332 | Failure = 1
|
---|
333 | leave
|
---|
334 | end
|
---|
335 | parse var rpcline token ':' tvalue
|
---|
336 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
337 | if Token = "NETNAME" then count = count + 1
|
---|
338 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
339 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
---|
340 | dyn = 'rpc.netshareenum.'count'.'Token' = "'Tvalue'"'
|
---|
341 | say " "dyn
|
---|
342 | interpret dyn
|
---|
343 | end
|
---|
344 | end
|
---|
345 | ok = stream(samba.!msg,'c','close')
|
---|
346 | ok = SysFileDelete(samba.!msg)
|
---|
347 | rpc.netshareenum.0 = count
|
---|
348 |
|
---|
349 | if Failure = 0 then do
|
---|
350 | retval = 1
|
---|
351 | rpc.netshareenum.LOGONSTATUS="OK"
|
---|
352 | end
|
---|
353 | else do
|
---|
354 | retval = 0
|
---|
355 | rpc.netshareenum.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
356 | end
|
---|
357 | IF options.!debug == 1 THEN SAY time()" _rpcnetshareenum() done, "retval" "rpc.netshareenum.LOGONSTATUS
|
---|
358 | return retval
|
---|
359 |
|
---|
360 | /*:VRX _rpcnetsharegetinfo
|
---|
361 | */
|
---|
362 | _rpcnetsharegetinfo: procedure expose rpc. samba. options.
|
---|
363 | IF options.!debug == 1 THEN SAY time()" _rpcnetsharegetinfo() started"
|
---|
364 | server = arg(1)
|
---|
365 | username = arg(2)
|
---|
366 | password = arg(3)
|
---|
367 | share = arg(4)
|
---|
368 |
|
---|
369 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="netsharegetinfo 'share'"'
|
---|
370 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="netsharegetinfo 'share'" >'samba.!msg
|
---|
371 |
|
---|
372 | rpc.netsharegetinfo. = ""
|
---|
373 |
|
---|
374 | Failure = 0
|
---|
375 |
|
---|
376 | do until lines(samba.!msg) = 0
|
---|
377 | rpcline = linein(samba.!msg)
|
---|
378 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
379 |
|
---|
380 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
381 | Failure = 1
|
---|
382 | leave
|
---|
383 | end
|
---|
384 | parse var rpcline token ':' tvalue
|
---|
385 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
386 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
387 | if pos('ACL',Token) = 0 & pos('ACE',Token) = 0 & pos('---',Token) = 0 & Token <> "" then do
|
---|
388 |
|
---|
389 | if Token = "TYPE" & left(Tvalue,2) = "0x" & length(Tvalue) = 3 then Token = "SHARETYPE"
|
---|
390 | if Token = "TYPE" & pos("SEC",Tvalue) > 1 then Token = "SECTYPE"
|
---|
391 |
|
---|
392 | dyn = 'rpc.netsharegetinfo.'Token' = "'Tvalue'"'
|
---|
393 | say " "dyn
|
---|
394 | interpret dyn
|
---|
395 | end
|
---|
396 | end
|
---|
397 | ok = stream(samba.!msg,'c','close')
|
---|
398 | ok = SysFileDelete(samba.!msg)
|
---|
399 |
|
---|
400 | if Failure = 0 then do
|
---|
401 | retval = '1'
|
---|
402 | rpc.netsharegetinfo.LOGONSTATUS="OK"
|
---|
403 | end
|
---|
404 | else do
|
---|
405 | retval = '0 '
|
---|
406 | rpc.netsharegetinfo.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
407 | end
|
---|
408 | IF options.!debug == 1 THEN SAY time()" _rpcnetsharegetinfo() done, "retval" "rpc.netsharegetinfo.LOGONSTATUS
|
---|
409 | return retval
|
---|
410 |
|
---|
411 | /*:VRX _rpcquerygroupmem
|
---|
412 | */
|
---|
413 | _rpcquerygroupmem: procedure expose rpc. samba. options.
|
---|
414 | IF options.!debug == 1 THEN SAY time()" _rpcquerygroupmem() started"
|
---|
415 | server = arg(1)
|
---|
416 | username = arg(2)
|
---|
417 | password = arg(3)
|
---|
418 | grouprid = arg(4)
|
---|
419 |
|
---|
420 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="querygroupmem 'grouprid'"'
|
---|
421 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="querygroupmem 'grouprid'" >'samba.!msg
|
---|
422 |
|
---|
423 | rpc.querygroupmem. = ""
|
---|
424 |
|
---|
425 | Failure = 0
|
---|
426 |
|
---|
427 | count = 0
|
---|
428 | do until lines(samba.!msg) = 0
|
---|
429 | rpcline = linein(samba.!msg)
|
---|
430 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
431 |
|
---|
432 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
433 | Failure = 1
|
---|
434 | leave
|
---|
435 | end
|
---|
436 | parse var rpcline 'rid:['trid'] attr:['tattr']'
|
---|
437 |
|
---|
438 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
439 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
440 | count = count + 1
|
---|
441 |
|
---|
442 | dyn = 'rpc.querygroupmem.'count'.RID = "'Trid'"'
|
---|
443 | say " "dyn
|
---|
444 | interpret dyn
|
---|
445 |
|
---|
446 | dyn = 'rpc.querygroupmem.'count'.ATTR = "'Tattr'"'
|
---|
447 | say " "dyn
|
---|
448 | interpret dyn
|
---|
449 |
|
---|
450 | end
|
---|
451 | ok = stream(samba.!msg,'c','close')
|
---|
452 | ok = SysFileDelete(samba.!msg)
|
---|
453 | rpc.querygroupmem.0 = count
|
---|
454 |
|
---|
455 | if Failure = 0 then do
|
---|
456 | retval = 1
|
---|
457 | rpc.querygroupmem.LOGONSTATUS="OK"
|
---|
458 | end
|
---|
459 | else do
|
---|
460 | retval = 0
|
---|
461 | rpc.querygroupmem.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
462 | end
|
---|
463 | IF options.!debug == 1 THEN SAY time()" _rpcquerygroupmem() done, "retval" "rpc.querygroupmem.LOGONSTATUS
|
---|
464 | return retval
|
---|
465 | /*:VRX _rpcqueryuser
|
---|
466 | */
|
---|
467 | _rpcqueryuser: procedure expose rpc. samba. options.
|
---|
468 | IF options.!debug == 1 THEN SAY time()" _rpcqueryuser() started"
|
---|
469 | server = arg(1)
|
---|
470 | username = arg(2)
|
---|
471 | password = arg(3)
|
---|
472 | userrid = arg(4)
|
---|
473 |
|
---|
474 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="queryuser 'userrid'"'
|
---|
475 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="queryuser 'userrid'" >'samba.!msg
|
---|
476 |
|
---|
477 | rpc.queryuser. = ""
|
---|
478 |
|
---|
479 | Failure = 0
|
---|
480 |
|
---|
481 | do until lines(samba.!msg) = 0
|
---|
482 | rpcline = linein(samba.!msg)
|
---|
483 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
484 |
|
---|
485 | if pos("NT_STATUS", rpcline) > 0 then do
|
---|
486 | Failure = 1
|
---|
487 | leave
|
---|
488 | end
|
---|
489 | if pos("TDB(", translate(rpcline)) > 0 then do
|
---|
490 | Failure = 1
|
---|
491 | /* provide a fake NT_STATUS */
|
---|
492 | rpcline = 'NT_STATUS_TDBERROR 'rpcline
|
---|
493 | leave
|
---|
494 | end
|
---|
495 |
|
---|
496 | parse var rpcline token ':' tvalue
|
---|
497 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
498 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
499 | if pos('[',Token) = 0 & pos('TABLE',Token) = 0 & Token <> "" then do
|
---|
500 | dyn = 'rpc.queryuser.'Token' = "'Tvalue'"'
|
---|
501 | say " "dyn
|
---|
502 | interpret dyn
|
---|
503 | end
|
---|
504 | end
|
---|
505 | ok = stream(samba.!msg,'c','close')
|
---|
506 | ok = SysFileDelete(samba.!msg)
|
---|
507 |
|
---|
508 | if Failure = 0 then do
|
---|
509 | retval = 1
|
---|
510 | rpc.queryuser.LOGONSTATUS="OK"
|
---|
511 | end
|
---|
512 | else do
|
---|
513 | retval = '0 '
|
---|
514 | rpc.queryuser.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
515 | end
|
---|
516 | IF options.!debug == 1 THEN SAY time()" _rpcqueryuser() done, "retval" "rpc.queryuser.LOGONSTATUS
|
---|
517 | return retval
|
---|
518 | /*:VRX _rpcsrvinfo
|
---|
519 | */
|
---|
520 | _rpcsrvinfo:
|
---|
521 | IF options.!debug == 1 THEN SAY time()" _rpcsrvinfo() started"
|
---|
522 | server = arg(1)
|
---|
523 | username = arg(2)
|
---|
524 | password = arg(3)
|
---|
525 |
|
---|
526 | say ' 'samba.!rpcclientexe' 'server' --user='username'%'password' --command="srvinfo"'
|
---|
527 | address cmd samba.!rpcclientexe' 'server' --user='username'%'password' --command="srvinfo" >'samba.!msg
|
---|
528 |
|
---|
529 | rpc.srvinfo. = ""
|
---|
530 |
|
---|
531 | Failure = 0
|
---|
532 |
|
---|
533 | do until lines(samba.!msg) = 0
|
---|
534 | rpcline = linein(samba.!msg)
|
---|
535 | if pos("creating default valid table",rpcline) <> 0 then iterate
|
---|
536 |
|
---|
537 | if pos("LOGON_FAILURE", rpcline) > 0 then do
|
---|
538 | Failure = 1
|
---|
539 | leave
|
---|
540 | end
|
---|
541 | if pos(':',rpcline) <> 0 then do
|
---|
542 | parse var rpcline token ':' tvalue
|
---|
543 | token = translate(strip(strip(translate(token),'L','09'x)),'_',' ')
|
---|
544 | tvalue= strip(strip(tvalue,'L','09'x))
|
---|
545 | dyn = 'rpc.srvinfo.'Token' = "'Tvalue'"'
|
---|
546 | say " "dyn
|
---|
547 | interpret dyn
|
---|
548 | end
|
---|
549 | else do
|
---|
550 | parse var rpcline '09'x rpc.srvinfo.NETBIOSNAME' 'rpc.srvinfo.SERVERSTRING
|
---|
551 | rpc.srvinfo.SERVERSTRING = strip(rpc.srvinfo.SERVERSTRING)
|
---|
552 | say ' rpc.srvinfo.NETBIOSNAME = "'rpc.srvinfo.NETBIOSNAME'"'
|
---|
553 | rpc.srvinfo.CAPABILITIES = ""
|
---|
554 | do I = 1 to words(rpc.srvinfo.SERVERSTRING)
|
---|
555 | if length(word(rpc.srvinfo.SERVERSTRING,I)) >=4 then leave
|
---|
556 | if length(word(rpc.srvinfo.SERVERSTRING,I)) = 2 | length(word(rpc.srvinfo.SERVERSTRING,I)) = 3 then do
|
---|
557 | rpc.srvinfo.CAPABILITIES = rpc.srvinfo.CAPABILITIES||word(rpc.srvinfo.SERVERSTRING,I)||' '
|
---|
558 | end
|
---|
559 | end
|
---|
560 | rpc.srvinfo.SERVERSTRING = strip(substr(rpc.srvinfo.SERVERSTRING,length(rpc.srvinfo.CAPABILITIES),))
|
---|
561 | rpc.srvinfo.CAPABILITIES = strip(rpc.srvinfo.CAPABILITIES)
|
---|
562 | say ' rpc.srvinfo.CAPABILITIES = "'rpc.srvinfo.CAPABILITIES'"'
|
---|
563 | say ' rpc.srvinfo.SERVERSTRING = "'rpc.srvinfo.SERVERSTRING'"'
|
---|
564 | end
|
---|
565 | end
|
---|
566 | ok = stream(samba.!msg,'c','close')
|
---|
567 | ok = SysFileDelete(samba.!msg)
|
---|
568 |
|
---|
569 | if Failure = 0 then do
|
---|
570 | retval = 1
|
---|
571 | rpc.srvinfo.LOGONSTATUS="OK"
|
---|
572 | end
|
---|
573 | else do
|
---|
574 | retval = 0
|
---|
575 | rpc.srvinfo.LOGONSTATUS=substr(rpcline,pos("NT_STATUS",rpcline),)
|
---|
576 | end
|
---|
577 | IF options.!debug == 1 THEN SAY time()" _rpcsrvinfo() done, "retval
|
---|
578 | return retval
|
---|
579 |
|
---|
580 | /*:VRX _ShowMsg
|
---|
581 | */
|
---|
582 | _ShowMsg:
|
---|
583 | Buttons.1 = "OK" /* NLVGetMessage(2) */
|
---|
584 | Buttons.0 = 1
|
---|
585 | id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
|
---|
586 | return
|
---|
587 | /*:VRX Fini
|
---|
588 | */
|
---|
589 | Fini:
|
---|
590 | window = VRWindow()
|
---|
591 | call VRSet window, "Visible", 0
|
---|
592 | drop window
|
---|
593 | return 0
|
---|
594 |
|
---|
595 | /*:VRX Halt
|
---|
596 | */
|
---|
597 | Halt:
|
---|
598 | signal _VREHalt
|
---|
599 | return
|
---|
600 |
|
---|
601 | /*:VRX Init
|
---|
602 | */
|
---|
603 | Init:
|
---|
604 | window = VRWindow()
|
---|
605 | call VRMethod window, "CenterWindow"
|
---|
606 | call VRSet window, "Visible", 1
|
---|
607 | call VRMethod window, "Activate"
|
---|
608 | drop window
|
---|
609 | return
|
---|
610 |
|
---|
611 | /*:VRX Main_Close
|
---|
612 | */
|
---|
613 | Main_Close:
|
---|
614 | call Quit
|
---|
615 | return
|
---|
616 |
|
---|
617 | /*:VRX Main_Create
|
---|
618 | */
|
---|
619 | Main_Create:
|
---|
620 | ok = VRRedirectStdio("ON")
|
---|
621 | options.!debug = 1
|
---|
622 |
|
---|
623 | call _InitTempDir
|
---|
624 | call _CltInit
|
---|
625 |
|
---|
626 | call _ContainerInit
|
---|
627 |
|
---|
628 | Credentials. =""
|
---|
629 |
|
---|
630 | call _ParseCommandLine
|
---|
631 |
|
---|
632 | if Credentials.!user = "" | Credentials.!password = "" then do
|
---|
633 | window = VRLoadSecondary( "SW_LOGIN", "W" )
|
---|
634 | end
|
---|
635 |
|
---|
636 | IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"'
|
---|
637 | IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"'
|
---|
638 | IF options.!debug == 1 THEN say ' Server ="'Server'"'
|
---|
639 | return
|
---|
640 |
|
---|
641 | /*:VRX PB_1_Click
|
---|
642 | */
|
---|
643 | PB_1_Click:
|
---|
644 |
|
---|
645 |
|
---|
646 | /* ok = _rpcquerygroupmem(server, Credentials.!username, Credentials.!password,'0x201') */
|
---|
647 | ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username)
|
---|
648 |
|
---|
649 | if ok = 1 then do
|
---|
650 | ok = VRSetIni( "SmbLogon", c2x(server), c2x(Credentials.!username)'#'c2x(Credentials.!password), "SYSTEM" )
|
---|
651 | end
|
---|
652 | else do
|
---|
653 | ok = VRDelIni( "SmbLogon", c2x(server),"SYSTEM")
|
---|
654 | end
|
---|
655 |
|
---|
656 | /* ok = _rpcenumprinters(server, Credentials.!username, Credentials.!password) */
|
---|
657 | /* ok = _rpcenumdomusers(server, Credentials.!username, Credentials.!password) */
|
---|
658 | /* ok = _rpcsrvinfo(server, Credentials.!username, Credentials.!password) */
|
---|
659 | /* ok = _rpcnetsharegetinfo(server, Credentials.!username, Credentials.!password,'data') */
|
---|
660 | /* ok = _rpcnetshareenum(server, Credentials.!username, Credentials.!password) */
|
---|
661 | return
|
---|
662 |
|
---|
663 | /*:VRX PB_Cancel_Click
|
---|
664 | */
|
---|
665 | PB_Cancel_Click:
|
---|
666 | call quit
|
---|
667 | return
|
---|
668 |
|
---|
669 | /*:VRX PB_LOGIN_CANCEL_Click
|
---|
670 | */
|
---|
671 | PB_LOGIN_CANCEL_Click:
|
---|
672 | call SW_LOGIN_Close
|
---|
673 | return 0
|
---|
674 |
|
---|
675 | /*:VRX PB_LOGIN_OK_Click
|
---|
676 | */
|
---|
677 | PB_LOGIN_OK_Click:
|
---|
678 | Credentials.!username = VRGet("EF_USER1","Value")
|
---|
679 | Credentials.!password = VRGet("EF_PASSWORD1","Value")
|
---|
680 | call SW_LOGIN_Close
|
---|
681 | return
|
---|
682 |
|
---|
683 | /*:VRX PB_Logon_Click
|
---|
684 | */
|
---|
685 | PB_Logon_Click:
|
---|
686 | ok = _rpcqueryuser(server, Credentials.!username, Credentials.!password,Credentials.!username)
|
---|
687 | LogonStatus = word(ok,1)
|
---|
688 |
|
---|
689 | if LogonStatus = "1" then Msg.Type ="I"
|
---|
690 | else Msg.Type ="E"
|
---|
691 | LogonWelcome = "Welcome" /* NLVGetMessage(x) */
|
---|
692 | ok = VRSet("DT_WELCOME","Caption", LogonWelcome' 'rpc.queryuser.FULL_NAME)
|
---|
693 |
|
---|
694 | ok = SysFileDelete(samba.!msg)
|
---|
695 | address cmd 'evfscli.exe attach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg
|
---|
696 | attach_rc = rc
|
---|
697 |
|
---|
698 | do until lines(samba.!msg) = 0
|
---|
699 | attachline = linein(samba.!msg)
|
---|
700 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
---|
701 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, attachline)
|
---|
702 | end
|
---|
703 | ok = stream(samba.!msg,'c','close')
|
---|
704 |
|
---|
705 | /* \mountpoint ;workgroup=...;server=...;share=...;user=...;password=...;master=...;mastertype=...;memlen=...;logfile=...;loglevel=...;easupport=...) */
|
---|
706 |
|
---|
707 | parse var rpc.queryuser.PROFILE_PATH '\\'server'\'pshare'\'puser
|
---|
708 |
|
---|
709 | pshare = 'netlogon'
|
---|
710 |
|
---|
711 | /* EVFSCLI MOUNT type mountpoint resource {R|W} [F] */
|
---|
712 | say 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W'
|
---|
713 | address cmd 'evfscli.exe mount SMBFS 'rpc.queryuser.DIR_DRIVE'\ WORKGROUP=;SERVER='server';share='pshare';user='Credentials.!username';password='Credentials.!password' W >'samba.!msg
|
---|
714 | mount_rc = rc
|
---|
715 | do until lines(samba.!msg) = 0
|
---|
716 | mountline = linein(samba.!msg)
|
---|
717 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
---|
718 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
|
---|
719 | end
|
---|
720 | ok = stream(samba.!msg,'c','close')
|
---|
721 |
|
---|
722 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
---|
723 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Start logon script")
|
---|
724 |
|
---|
725 | ok = Value('OS','ECS','OS2ENVIRONMENT')
|
---|
726 | address cmd rpc.queryuser.DIR_DRIVE'\'rpc.queryuser.LOGON_SCRIPT' >'samba.!msg
|
---|
727 | do until lines(samba.!msg) = 0
|
---|
728 | mountline = linein(samba.!msg)
|
---|
729 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
---|
730 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
|
---|
731 | end
|
---|
732 | ok = stream(samba.!msg,'c','close')
|
---|
733 |
|
---|
734 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
---|
735 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, "Logon script done.")
|
---|
736 |
|
---|
737 | say 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE
|
---|
738 | address cmd 'evfscli.exe detach 'rpc.queryuser.DIR_DRIVE' >'samba.!msg
|
---|
739 | do until lines(samba.!msg) = 0
|
---|
740 | mountline = linein(samba.!msg)
|
---|
741 | rh = VRMethod( "CN_STATUS", "AddRecord")
|
---|
742 | ok = VRMethod( "CN_STATUS", "SetFieldData", rh, Status.MessageFH, mountline)
|
---|
743 | end
|
---|
744 | ok = stream(samba.!msg,'c','close')
|
---|
745 | return
|
---|
746 |
|
---|
747 | /*:VRX Quit
|
---|
748 | */
|
---|
749 | Quit:
|
---|
750 | call _SambaFinish
|
---|
751 | window = VRWindow()
|
---|
752 | call VRSet window, "Shutdown", 1
|
---|
753 | drop window
|
---|
754 | return
|
---|
755 |
|
---|
756 | /*:VRX SW_LOGIN_Close
|
---|
757 | */
|
---|
758 | SW_LOGIN_Close:
|
---|
759 | call SW_LOGIN_Fini
|
---|
760 | return
|
---|
761 |
|
---|
762 | /*:VRX SW_LOGIN_Create
|
---|
763 | */
|
---|
764 | SW_LOGIN_Create:
|
---|
765 | call SW_LOGIN_Init
|
---|
766 | /* CALL NLVSetText 'DT_USER1', 'Caption', 25
|
---|
767 | CALL NLVSetText 'DT_PASSWORD1', 'Caption', 26
|
---|
768 | CALL NLVSetText 'PB_LOGIN_OK', 'Caption', 2
|
---|
769 | CALL NLVSetText 'PB_LOGIN_CANCEL','Caption', 3 */
|
---|
770 |
|
---|
771 | ok = VRSet("EF_User1","Value", Credentials.!Username)
|
---|
772 | ok = VRSet("EF_PASSWORD1","Value",Credentials.!password)
|
---|
773 | return
|
---|
774 |
|
---|
775 | /*:VRX SW_LOGIN_Fini
|
---|
776 | */
|
---|
777 | SW_LOGIN_Fini:
|
---|
778 | window = VRInfo( "Window" )
|
---|
779 | call VRDestroy window
|
---|
780 | drop window
|
---|
781 | return
|
---|
782 | /*:VRX SW_LOGIN_Init
|
---|
783 | */
|
---|
784 | SW_LOGIN_Init:
|
---|
785 | window = VRInfo( "Object" )
|
---|
786 | if( \VRIsChildOf( window, "Notebook" ) ) then do
|
---|
787 | call VRMethod window, "CenterWindow"
|
---|
788 | call VRSet window, "Visible", 1
|
---|
789 | call VRMethod window, "Activate"
|
---|
790 | end
|
---|
791 | drop window
|
---|
792 | return
|
---|
793 |
|
---|