source: branches/guitools-1.0/smbusers/smbusers.VRX@ 408

Last change on this file since 408 was 408, checked in by Herwig Bauernfeind, 15 years ago

GUI-Tools: SSCC 0.9.5, SMBUsers 0.9.6 several fixes

File size: 141.1 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\guitools-1.0\shared\nlv.vrs
94#append U:\Develop\Samba\guitools-1.0\shared\inittempDir.vrs
95#append U:\Develop\Samba\guitools-1.0\shared\sambainit.vrs
96#append U:\Develop\Samba\guitools-1.0\shared\swat.vrs
97*/
98return
99/*:VRX _ColumnShow
100*/
101_ColumnShow:
102 userdata = VRGet(VRInfo("OBject"),"Userdata")
103 parse var userdata Container '|' fieldh '|' VisStatus
104say userdata
105 ok = VRMethod(Container,"SetFieldAttr", fieldh, "Visible", \VisStatus )
106return
107
108/*:VRX _ColumnsMenu
109*/
110_ColumnsMenu:
111 Container = arg(1)
112 ok = VRMethod(Container, "GetFieldList", "Fields." )
113
114 do I = 1 to 17
115 if I <= fields.0 then do
116/* say "Columns_"||right("0"||I,2)' 'VRMethod(Container, "GetFieldAttr", fields.I, "Title" ) */
117 ok = VRset("Columns_"||right("0"||I,2), "Visible", 1)
118 ok = VRset("Columns_"||right("0"||I,2), "Caption", VRMethod(Container, "GetFieldAttr", fields.I, "Title" ))
119 ok = VRset("Columns_"||right("0"||I,2), "Checked", VRMethod(Container, "GetFieldAttr", fields.I, "Visible" ))
120 ok = VRset("Columns_"||right("0"||I,2), "Userdata", Container'|'fields.I'|'VRMethod(Container, "GetFieldAttr", fields.I, "Visible" ))
121 end
122 else ok = VRset("Columns_"||right("0"||I,2), "Visible", 0)
123 end
124 ok = VRMethod( "Columns", "Popup", , , "", "" )
125return
126
127/*:VRX _ContainerPopulate
128*/
129_ContainerPopulate:
130 IF options.!debug == 1 THEN say '_ContainerPopulate() started'
131 ok = VRSet("CN_Users","Painting", 0 )
132 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
133 if SelRH.0 <> 0 then SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
134 else SelNr = 0
135 IF options.!debug == 1 then say ' Selected User Nr = 'SelNr
136 ok = VRMethod("CN_Users","RemoveRecord", "ALL")
137 drop RH.
138
139 do i = 1 to username.0
140 RH.i = VRMethod("CN_Users", "AddRecord", , , username.I , "#29" )
141
142 ok = VRMethod("CN_Users","SetFieldData", RH.i, NrFH, I, UsernameFH, username.I, UIDFH, Uid.I, GIDFH, GID.I, GECOSFH, GECOS.I, HomeFH, _PathStrOS2(Home.I), ShellFH, Shell.I)
143 ok = VRMethod("CN_Users","SetFieldData", RH.i, xpwFH, password.i,xlcFH,LoginClass.I,xcpwFH, pwchange.I,xDeactFH, deact.I )
144 /* smbpasswd fields */
145 ok = VRMethod("CN_Users","SetFieldData", RH.i, FLagsFH, flags.I, LMHashFH, LMHash.I,NTHashFH, NTHash.I, LCTFH, LCT.I)
146 /* smbusermap field */
147 ok = VRMethod( "CN_Users", "SetFieldData", RH.i, MapToFH, MapTo.I)
148 /* private field */
149 ok = VRMethod( "CN_Users", "SetFieldData", RH.i, StatusFH, Status.I)
150
151 if (flags.i = "" & settings.!SmbOnly) then do
152 ok = VRMethod( "CN_Users", "SetRecordAttr", RH.i, "Visible", 0)
153 end
154 end
155 RH.0 = username.0
156 if SelNr <= I & SelNr <> 0 & Username.0 > 0 then do
157 MSelNr = Min(SelNr, Username.0)
158 ok = VRMethod("CN_Users", "SetRecordAttr", RH.MSelNr, "Selected", 1)
159 end
160 ok = VRMethod("CN_users", "Arrange")
161 ok = VRSet("CN_Users","Painting", 1 )
162 IF options.!debug == 1 THEN say '_ContainerPopulate() done'
163return
164
165/*:VRX _ContainersInit
166*/
167_ContainersInit:
168 /* User */
169 NrFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(130) )
170 FlagsFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(131) ) /* smbpasswd */
171 UsernameFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(132) ) /* master.passwd and smbpasswd */
172 xpwFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(133) ) /* master.passwd, not used */
173 UIDFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(134) ) /* master.passwd and smbpasswd */
174 GeCOSFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(135) ) /* master.passwd */
175 GIDFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(136) ) /* master.passwd */
176 xlcFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(137) ) /* master.passwd, not used */
177 xcpwFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(138) ) /* master.passwd, not used */
178 xDeactFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(139) ) /* master.passwd, not used */
179 HomeFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(140) ) /* master.passwd */
180 ShellFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(141) ) /* master.passwd, not used */
181 LMHashFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(142) ) /* smbpasswd */
182 NTHashFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(143) ) /* smbpasswd */
183 LCTFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(144) ) /* smbpasswd */
184 MapToFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(145) ) /* smbusermap */
185 StatusFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(146) )
186
187/* ok = VRSet("CN_Users","LastSplitfield", MapToFH)
188 ok = VRSet("CN_Users","SplitBarLeft", VRGet("CN_Users","Width")*0.90) */
189
190 ok = VRMethod("CN_Users","SetfieldAttr",NrFH, "ReadOnly", 1, "Justification", "Right")
191 ok = VRMethod("CN_Users","SetfieldAttr",FlagsFH, "ReadOnly", 1)
192 ok = VRMethod("CN_Users","SetfieldAttr",UserNameFH,"ReadOnly", 1)
193 ok = VRMethod("CN_Users","SetfieldAttr",GIDFH, "Justification", "Right" )
194 ok = VRMethod("CN_Users","SetfieldAttr",UIDFH, "ReadOnly", 1, "Justification", "Right" )
195 ok = VRMethod("CN_Users","SetfieldAttr",LCTFH, "ReadOnly", 1)
196 ok = VRMethod("CN_Users","SetfieldAttr",LMHashFH, "ReadOnly", 1)
197 ok = VRMethod("CN_Users","SetfieldAttr",NTHashFH, "ReadOnly", 1)
198
199 ok = VRMethod("CN_Users","SetfieldAttr",xpwFH, "Visible", 0)
200 ok = VRMethod("CN_Users","SetfieldAttr",xlcFH, "Visible", 0)
201 ok = VRMethod("CN_Users","SetfieldAttr",xcpwFH, "Visible", 0)
202 ok = VRMethod("CN_Users","SetfieldAttr",xDeactFH, "Visible", 0)
203 ok = VRMethod("CN_Users","SetfieldAttr",LMHashFH, "Visible", 0)
204 ok = VRMethod("CN_Users","SetfieldAttr",NTHashFH, "Visible", 0)
205 ok = VRMethod("CN_Users","SetfieldAttr",ShellFH, "Visible", 0)
206 ok = VRMethod("CN_Users","SetfieldAttr",LCTFH, "Visible", 0)
207
208 if samba.!smbusermap = "" then do
209 ok = VRMethod("CN_Users","SetfieldAttr",MapToFH, "Visible", 0)
210 ok = VRMethod("CN_Users","SetfieldAttr",MapToFH, "ReadOnly", 1)
211 end
212
213
214 /* master.passwd syntax:
215 Username:password:UID:GID:Login-Class:Change pw in x seconds:Deactivate in x seconds:GECOS (Fullname):HOME:SHELL */
216
217 /* smbpasswd syntax:
218 Username:UID:Lanman Password Hash:NT Password Hash:flags:LCT (Last Change Time) */
219
220 GNrFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(130) ) /* private */
221 GroupNameFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(150) ) /* group */
222 NTGroupNameFH= VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(151) ) /* net group */
223 GpasswdFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(152) ) /* group, not used */
224 GGIDFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(153) ) /* group */
225 GUsersFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(154) ) /* group */
226 SIDFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(155) ) /* net group */
227 RIDFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(156) ) /* net group */
228 NTCommentFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(157) ) /* net group */
229 NTGroupTypeFH= VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(158) ) /* net group */
230 GStatusFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(159) ) /* private */
231
232 ok = VRMethod("CN_Groups","SetfieldAttr",GNrFH,"ReadOnly", 1, "Justification", "Right")
233 ok = VRMethod("CN_Groups","SetfieldAttr",GroupnameFH,"ReadOnly", 1)
234 ok = VRMethod("CN_Groups","SetfieldAttr",NTGroupnameFH,"ReadOnly", 1)
235 ok = VRMethod("CN_Groups","SetfieldAttr",NTCommentFH,"ReadOnly", 1)
236 ok = VRMethod("CN_Groups","SetfieldAttr",NTGroupTypeFH,"ReadOnly", 1)
237 ok = VRMethod("CN_Groups","SetfieldAttr",SIDFH,"ReadOnly", 1)
238 ok = VRMethod("CN_Groups","SetfieldAttr",SIDFH,"Visible", 0)
239 ok = VRMethod("CN_Groups","SetfieldAttr",RIDFH,"ReadOnly", 1)
240 ok = VRMethod("CN_Groups","SetfieldAttr",GGIDFH,"ReadOnly", 1, "Justification", "Right")
241 ok = VRMethod("CN_Groups","SetfieldAttr",GPasswdFH, "Visible", 0)
242 ok = VRMethod("CN_Groups","SetfieldAttr",GPasswdFH, "ReadOnly", 1)
243return
244
245/*:VRX _ContGroupsPopulate
246*/
247_ContGroupsPopulate:
248 IF options.!debug == 1 then say '_ContGroupsPopulate() started.'
249 ok = VRSet("CN_Groups","Painting", 0 )
250 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
251 if SelGRH.0 <> 0 then SelGNr = VRMethod("CN_Users", "GetFieldData", SelGRH.1, GNrFH)
252 else SelGNr = 0
253 IF options.!debug == 1 then say ' Selected Group Nr = 'SelGNr
254 ok = VRMethod("CN_Groups","RemoveRecord", "ALL")
255 drop GRH.
256
257 do i = 1 to Groupname.0
258 GRH.i = VRMethod("CN_Groups", "AddRecord", , , Groupname.I , "#50" )
259 ok = VRMethod("CN_Groups","SetFieldData", GRH.i, GNrFH, I, GroupnameFH, Groupname.I, GGIDFH, GGid.I, GUsersFH, Gusers.I )
260 /* private field */
261 ok = VRMethod( "CN_Groups", "SetFieldData", GRH.i, GpasswdFH, Gpasswd.I, NTGroupNameFH, NTGroupName.I, RIDFH, RID.I, SIDFH, SID.I,NTCommentFH, NTComment.I, NTGroupTypeFH, NTGroupType.I,GStatusFH, GStatus.I)
262 if (RID.i = "" & settings.!SmbGroupsOnly) then do
263 ok = VRMethod( "CN_Groups", "SetRecordAttr", GRH.i, "Visible", 0)
264 end
265 end
266 GRH.0 = Groupname.0
267 if SelGNr <= I & SelGNr <> 0 & Groupname.0 > 0 then ok = VRMethod("CN_Groups", "SetRecordAttr", GRH.SelGNr, "Selected", 1)
268 ok = VRMethod("CN_Groups", "Arrange")
269 ok = VRSet("CN_Groups","Painting", 1 )
270 IF options.!debug == 1 then say '_ContGroupsPopulate() done.'
271return
272
273/*:VRX _DirDialog
274*/
275_DirDialog: procedure
276 Title = arg(1)
277 InitDir = arg(2)
278 RC = RxFuncQuery("DRCtrlPickDirectory")
279 if RC = 0 then do /* use DrCtrl if available */
280 MyDir=DRCtrlPickDirectory(InitDir, Title)
281 end
282 else do
283 MyDir = VRFileDialog(VRWindow,Title, 'o', InitDir||'\dummy')
284 if MyDir <> '' then MyDir = strip(filespec('D',MyDir)||Filespec('P',MyDir),'T','\')
285 end
286return MyDir
287/*:VRX _GetNextGID
288*/
289_GetNextGID: procedure expose MinGGID GGID.
290 say "_GetNextGID() started"
291 do nextGID = minGGID to 65535 by 1
292 do i=1 to GGID.0 while GGID.i <> nextGID
293 end
294 if GGID.i <> nextGID then leave
295 end
296 say "_GetNextGID() done, returning "nextGID
297return nextGID
298/*:VRX _GetNextUID
299*/
300_GetNextUID: procedure expose MinUID UID.
301 nextusername = translate(arg(1))
302 say "_GetNextUID() started"
303 do nextUID = minUID to 65535 by 1
304 do i=1 to UID.0 while UID.i <> nextUID
305 end
306 if uid.i <> nextUID then leave
307 end
308 if translate(nextusername) = "ROOT" then NextUID = 0
309 if translate(nextusername) = "GUEST" then NextUID = 65534
310 if translate(nextusername) = "NOBODY" then NextUID = 65533
311 say "_GetNextUID() done, returning "nextUID
312return nextUID
313/*:VRX _GroupRead
314*/
315_GroupRead:
316 IF options.!debug == 1 THEN say '_GroupRead() started'
317 /* Read complete group file */
318 I = 0
319 do while lines(samba.!group) <> 0
320 groupline = strip(linein(samba.!group))
321
322 /* Skip comments */
323 if left(groupline,1) = "#" then iterate
324 if left(groupline,1) = ";" then iterate
325
326 /* parse fields into stem variables */
327 I = I + 1
328
329 parse var groupline groupname.I':'Gpasswd.I':'GGid.I':'Gusers.I
330
331 GStatus.I =""
332 if pos(',,',GUsers.I) > 0 then GStatus.I='DOUBLE COMMA FOUND'
333 if right(GUsers.I,1) <> ',' & Gusers.I <> "" then GStatus.I='MISSING TRAILING COMMA'
334 do J = 1 to I - 1
335 if translate(groupname.J) = translate(groupname.I) then do
336 gstatus.I = "DUPLICATE"
337 leave
338 end
339 end
340 blGUsers = translate(translate(Gusers.I,' ',','))
341 do J = 1 to Username.0
342 UPos = wordpos(translate(Username.J),blGusers)
343 if Upos > 0 then blGUsers = delword(BlGusers,UPos,1)
344 if GID.J = GGID.I & UPos = 0 then do
345 Gusers.I = strip(Gusers.I||Username.J,,',')','
346 GStatus.I = 'MISSING USERS ADDED'
347 end
348 end
349 if strip(BlGusers) <> "" then gstatus.I = "NONEXISTENT USER"
350 end
351 ok = stream(samba.!group,'c','close')
352
353 NTGroupname. = ""
354 NTComment. = ""
355 NTGroupType. = ""
356 RID. = ""
357 SID. = ""
358 /* set "stem roots" properly */
359 groupname.0 = I
360 gpasswd.0 = I
361 ggid.0 = I
362 gusers.0 = I
363 NTGroupname.0 = I
364 NTComment.0 = I
365 NTGroupType.0 = I
366 SID.0 = I
367 RID.0 = I
368
369 /* our private stem */
370 gstatus.0 = I
371 IF options.!debug == 1 THEN say '_GroupRead() done, read 'groupname.0' kLIBC groups'
372return
373
374/*:VRX _GroupRecWriteBackToStems
375*/
376_GroupRecWriteBackToStems:
377 Cur = VRMethod("CN_Groups","GetFieldData", GRH, GNrFH)
378 Groupname.Cur = VRMethod("CN_Groups","GetFieldData", GRH, GroupnameFH)
379 GGID.Cur = VRMethod("CN_Groups","GetFieldData", GRH, GGIDFH)
380 GUsers.Cur = VRMethod("CN_Groups","GetFieldData", GRH, GusersFH)
381 if Gusers.Cur = "," then Gusers.Cur = ""
382return
383
384/*:VRX _GroupWrite
385*/
386_GroupWrite:
387 IF options.!debug == 1 THEN say '_GroupWrite() started'
388 newgroup = TempDir'group'
389 ok = SysFileDelete(newgroup)
390 call lineout newgroup, '# Created by smbusers Version 'word(VRGet("Main", "Hinttext"),2)
391 call lineout newgroup, '# syntax:'
392 call lineout newgroup, '# groupname:password:GID:user[,user,...,]'
393 do I = 1 to groupname.0
394 say "GUsers."I"="Gusers.I
395 if settings.!FixErrors then do
396 if Gusers.I = "," then Gusers.I = ""
397 if pos(',,',Gusers.I) > 0 then do
398 blGUsers = translate(Gusers.I,' ',',')
399 Gusers.I = ""
400 do ii = 1 to words(blGusers)
401 Gusers.I = GUsers.I||word(blGusers,II)||','
402 end
403 end
404 if Gusers.I <> "" & right(Gusers.I,1) <> ',' then GUsers.I = Gusers.I||','
405 end
406 NewUsers = ""
407 select
408 when GStatus.I = "DUPLICATE" & settings.!FixErrors then iterate
409 when GStatus.I = "NONEXISTENT USER" & settings.!FixErrors then do
410 blGUsers = translate(translate(Gusers.I,' ',','))
411 do J = 1 to Username.0
412 UPos = wordpos(translate(Username.J),blGusers)
413 if Upos > 0 then NewUsers = NewUsers||UserName.J','
414 end
415 call lineout newgroup, groupname.I':'Gpasswd.I':'GGid.I':'strip(NewUsers,'L',',')
416 end
417 otherwise call lineout newgroup, groupname.I':'Gpasswd.I':'GGid.I':'strip(GUsers.I,'L',',')
418 end
419 end
420 ok = stream(newgroup,'c','close')
421 ok = VRCopyFile( samba.!group, samba.!group'.bak' )
422 ok = VRCopyFile( newgroup, samba.!group )
423 ok = SysFileDelete(newgroup)
424 IF options.!debug == 1 THEN say '_GroupWrite() done'
425return
426
427/*:VRX _GUIINit
428*/
429_GUIINit:
430 IF options.!debug == 1 THEN say '_GUIInit() started'
431 ok = VRset("Main","Width",11000)
432 call Paper_Init
433
434 if datatype(Top) = 'NUM' then do
435 ok = VRset("Main","Top",Top)
436 ok = VRset("Main","Left",Left)
437 ok = VRset("Main","Width",max(Width,11000))
438 ok = VRset("Main","Height",Height)
439 end
440 ok = VRSet("Main","Font", Font_Main)
441 ok = VRSet("Main","Statusfont", Font_Status)
442 ok = VRSet("Page_1","Font", Font_Page_1)
443 ok = VRSet("Page_2","Font", Font_Page_2)
444 ok = VRSet("Page_4","Font", Font_Page_3)
445 ok = VRSet("Page_3","Font", Font_Page_4)
446 ok = VRSet("Page_5","Font", Font_Page_5)
447 Buttonwidth = VRMethod( "Screen", "PixelsToTwips", 32 )
448
449 ok = VRSet("CB_SmbOnly","set", settings.!SmbOnly)
450 ok = VRSet("CB_SmbGroupsOnly","set", settings.!SmbGroupsOnly)
451 ok = VRSet("CB_SyncFullName","set", settings.!SyncFullName)
452 ok = VRSet("CB_SyncPrimGID","set", settings.!SyncPrimGID)
453
454 call _INILayoutRead "CN_Users"
455 call _INILayoutRead "CN_Groups"
456
457 if _ChkTempFreeSpace() < 262144 then do
458 Msg.Type = "W"
459 Msg.Text = NLVGetMessage(180, TempDir)
460 call _ShowMsg
461 end
462
463 ok = VRSet("Main", "Visible", 1)
464 IF options.!debug == 1 THEN say '_GUIInit() done'
465return
466
467/*:VRX _INILayoutRead
468*/
469_INILayoutRead:
470 Container = arg(1)
471 ok = VRMethod(Container, "GetFieldList", "Fields." )
472 Layout = VRGetIni( "Layout", Container, OurINI )
473 if Layout = "" then return
474 do I = 1 to Fields.0
475 ok = VRMethod(Container, "SetFieldAttr", fields.I,"Visible", substr(Layout,I,1))
476 end
477return
478
479/*:VRX _INILayoutWrite
480*/
481_INILayoutWrite:
482 Container = arg(1)
483 ok = VRMethod(Container, "GetFieldList", "Fields." )
484 Layout = ""
485 do I = 1 to fields.0
486 Layout = Layout||VRMethod(Container, "GetFieldAttr", fields.I, "Visible" )
487 end
488 ok = VRSetIni( "Layout", Container , Layout, OurINI, 'NoClose' )
489return
490
491/*:VRX _INIRead
492*/
493_INIRead:
494 IF options.!debug == 1 THEN say '_INIRead() started'
495 OurINI = strip(VRParseFileName(VRget("Application","Program"),'DP')'\SMBUSERS.INI',,'\')
496 ok = SysFileTree(OurINI, INIFound.,'FO')
497 if INIFound.0 = 1 then OurINI = VRParseFileName(INIFound.1,'DPNE')
498 IF options.!debug == 1 THEN say 'OurINI = "'OurINI'"'
499
500 Top = VRGetIni( "Pos", "Top", OurINI , 'NoClose')
501 Left = VRGetIni( "Pos", "Left", OurINI , 'NoClose')
502 Width = VRGetIni( "Pos", "Width", OurINI , 'NoClose')
503 Height= VRGetIni( "Pos", "Height", OurINI , 'NoClose')
504
505 Font_Page_1 = VRGetIni( "Fonts", "Page_1", OurINI , 'NoClose' )
506 Font_Page_2 = VRGetIni( "Fonts", "Page_2", OurINI , 'NoClose' )
507 Font_Page_3 = VRGetIni( "Fonts", "Page_4", OurINI , 'NoClose' )
508 Font_Page_4 = VRGetIni( "Fonts", "Page_3", OurINI , 'NoClose' )
509 Font_Page_5 = VRGetIni( "Fonts", "Page_5", OurINI , 'NoClose' )
510 Font_Main = VRGetIni( "Fonts", "Main", OurINI , 'NoClose' )
511 Font_Status = VRGetIni( "Fonts", "Statusfont", OurINI , 'NoClose' )
512
513 if Font_Page_1 = "" then Font_Page_1 = "8.Helv"
514 if Font_Page_2 = "" then Font_Page_2 = "8.Helv"
515 if Font_Page_3 = "" then Font_Page_3 = "8.Helv"
516 if Font_Page_4 = "" then Font_Page_4 = "8.Helv"
517 if Font_Page_5 = "" then Font_Page_5 = "8.Helv"
518 if Font_Main = "" then Font_Main = "8.Helv"
519 if Font_Status = "" then Font_Status = "8.Helv"
520
521 settings.!SmbOnly = VRGetIni( "Settings", "SmbOnly", OurINI)
522 if settings.!SmbOnly = "" then settings.!SmbOnly = 0
523
524 settings.!SmbGroupsOnly = VRGetIni( "Settings", "SmbGroupsOnly", OurINI)
525 if settings.!SmbGroupsOnly = "" then settings.!SmbGroupsOnly = 0
526
527 settings.!FixErrors = VRGetIni( "Settings", "FixErrors", OurINI)
528 if settings.!FixErrors = "" then settings.!FixErrors = 1
529
530 settings.!SyncFullName = VRGetIni( "Settings", "SyncFullName", OurINI)
531 if settings.!SyncFullName = "" then settings.!SyncFullName = 1
532
533 settings.!SyncPrimGID = VRGetIni( "Settings", "SyncPrimGID", OurINI)
534 if settings.!SyncPrimGID = "" then settings.!SyncPrimGID = 0
535
536 options.!debug = VRGetIni( "Options", "Debug", OurINI)
537 if options.!debug = "" then options.!debug = 0
538
539 ok = VRSet("CB_Debug","set",options.!Debug)
540 if options.!Debug then ok = VRREdirectStdIO("ON")
541 else ok = VRREdirectStdIO("OFF")
542
543 smbdoutput = 'smbd.out'
544 sambaver = ''
545
546 MinUID = 100
547 MinGGID = 3000
548 msg = ''
549 Credentials. = ''
550
551 IF options.!debug == 1 THEN say '_INIRead() done'
552return
553
554/*:VRX _INIWrite
555*/
556_INIWrite:
557 say 'start _INIWrite()'
558 ok = VRSetIni( "Pos", "Top", VRGet("Main","Top"), OurINI, 'NoClose' )
559 ok = VRSetIni( "Pos", "Left", VRGet("Main","Left"), OurINI, 'NoClose' )
560 ok = VRSetIni( "Pos", "Width", VRGet("Main","Width"), OurINI, 'NoClose' )
561 ok = VRSetIni( "Pos", "Height", VRGet("Main","Height"), OurINI, 'NoClose' )
562 ok = VRSetIni( "Settings", "SmbOnly", settings.!SmbOnly, OurINI, 'NoClose' )
563 ok = VRSetIni( "Settings", "SmbGroupsOnly", settings.!SmbGroupsOnly, OurINI, 'NoClose' )
564 ok = VRSetIni( "Settings", "FixErrors", settings.!FixErrors, OurINI, 'NoClose' )
565 ok = VRSetIni( "Settings", "SyncFullName", settings.!SyncFullName, OurINI, 'NoClose' )
566 ok = VRSetIni( "Settings", "SyncPrimGID" , settings.!SyncPrimGID , OurINI, 'NoClose' )
567 ok = VRSetIni( "Options", "Debug", options.!debug, OurINI, 'NoClose' )
568
569 if VRget("CN_Users", "Font") <> "<default>" then ok = VRset("Page_1", "Font", VRget("CN_Users", "Font"))
570 if VRget("CN_Groups", "Font") <> "<default>" then ok = VRset("Page_2", "Font", VRget("CN_Groups", "Font"))
571
572 call _INILayoutWrite "CN_Users"
573 call _INILayoutWrite "CN_Groups"
574
575 ok = VRSetIni( "Fonts", "Page_1", VRGet("Page_1","Font"), OurINI, 'NoClose' )
576 ok = VRSetIni( "Fonts", "Page_2", VRGet("Page_2","Font"), OurINI, 'NoClose' )
577 ok = VRSetIni( "Fonts", "Page_4", VRGet("Page_4","Font"), OurINI, 'NoClose' )
578 ok = VRSetIni( "Fonts", "Page_3", VRGet("Page_3","Font"), OurINI, 'NoClose' )
579 ok = VRSetIni( "Fonts", "Page_5", VRGet("Page_5","Font"), OurINI, 'NoClose' )
580 ok = VRSetIni( "Fonts", "Statusfont", VRGet("Main","Statusfont"), OurINI, 'NoClose' )
581 ok = VRSetIni( "Fonts", "Main", VRGet("Main","Font"), OurINI )
582 say 'done _INIWrite()'
583return
584
585/*:VRX _kLIBCGroupAdd
586*/
587_kLIBCGroupAdd:
588 NewGroupName = arg(1)
589 NewGroupGGID = arg(2)
590
591 nx = Groupname.0 + 1
592 Groupname.0 = nx
593 groupname.nx = NewGroupName
594 Gpasswd.nx ="*"
595 GGid.nx = NewGroupGGID
596 Gusers.nx = ""
597 NTGroupname.nx = ""
598 NTComment.nx = ""
599 RID.nx = ""
600 gstatus.nx = ""
601return
602
603/*:VRX _LoadotherFuncs
604*/
605_LoadotherFuncs:
606 IF options.!debug == 1 THEN say "_LoadotherFuncs() started"
607 ok = VRRedirectStdIO("ON")
608 /* ELSE ok = VRRedirectStdIO("OFF") */
609
610 /* what REXX script would be complete without this... */
611 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
612 call SysLoadFuncs
613
614 call rxfuncadd 'IniLoadFuncs', 'REXXINI', 'IniLoadFuncs'
615 call IniLoadFuncs
616
617 /* Deal with DRCtrlxxx */
618 RC = RxFuncQuery("DRCtrlPickDirectory")
619 if RC = 1 then do /* DRCtrlXXX not already registered */
620 /* Load DRCtrl functions */
621 ok = RxFuncAdd('DRCtrlLoadFuncs', 'drctl017', 'DRCtrlLoadFuncs')
622 if ok = 0 then CALL DRCtrlLoadFuncs
623 end
624
625 IF options.!debug == 1 THEN say "_LoadotherFuncs() done"
626return
627
628/*:VRX _Login
629*/
630_Login:
631 IF options.!debug == 1 THEN say "_Login() started"
632 if Credentials.!username <> "" then do
633 if \_UserIsValid(Credentials.!username) then do
634 Msg.Type ="E"
635 Msg.Title= VRget("Main","Caption")
636 Msg.Text = NLVGetMessage(111, Credentials.!username )
637 call _ShowMsg
638 Credentials.!username = "root"
639 Credentials.!password = ""
640 end
641 end
642 LoginStatus = ""
643
644EnterCredentials:
645 if Credentials.!username = "" | Credentials.!password = "" then window = VRLoadSecondary( "SW_LOGIN", "W" )
646
647 if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0
648 then UserCred = '--user='Credentials.!username'%'Credentials.!password
649 else UserCred = '--user='Credentials.!username'%%'Credentials.!password
650
651 /* Lets see if the credentials are good */
652 ok = VRSet("Main", 'Pointer', 'Wait' )
653 say ' 'samba.!netexe' rpc user 'DebugLevel' 'UserCred' 1>'samba.!msg
654 address cmd samba.!netexe' rpc user 'DebugLevel' 'UserCred' 1>'samba.!msg
655 ok = VRSet("Main", 'Pointer', '<default>' )
656 loginLine = linein(samba.!msg)
657 ok = stream(samba.!msg,'c','close')
658
659 /* If did not get a valid user back i.e. the first entry of the list, login was not successful */
660 if \_UserIsValid(strip(loginLine)) then do
661 Msg.Title = NLVGetMessage(31)': 'Credentials.!username'@'copies('*',length(Credentials.!password))
662 Msg.Text = SysGetMessage(65)
663 Msg.Type = "E"
664 call _ShowMsg
665 Credentials.!username = ""
666 Credentials.!password = ""
667 IF options.!debug == 1 THEN say '_Login() failed, credentials used were "'UserCred'"'
668 signal EnterCredentials
669 end
670
671 IF options.!debug == 1 THEN say '_Login() succeeded, credentials used are "'UserCred'"'
672return
673
674/*:VRX _MasterpasswdRead
675*/
676_MasterpasswdRead:
677 IF options.!debug == 1 THEN say '_MasterpasswdRead() started'
678 /* Read complete master.passwd */
679 I = 0
680
681 do until lines(samba.!masterpasswd) = 0
682 userline = strip(linein(samba.!masterpasswd))
683
684 /* Skip comments */
685 if left(userline,1) = "#" then iterate
686 if left(userline,1) = ";" then iterate
687
688 /* parse fields into stem variables */
689 I = I + 1
690 parse var userline username.I':'password.I':'uid.I':'gid.I':'LoginClass.I':'pwchange.I':'deact.I':'gecos.I':'home.I':'shell.I
691
692 Status.I =""
693 do J = 1 to I - 1
694 if translate(Username.J) = translate(Username.I) then do
695 status.I = "DUPLICATE"
696 leave
697 end
698 end
699 end
700 ok = stream(samba.!masterpasswd,'c','close')
701 drop userline
702
703 /* set "stem roots" properly */
704 username.0 = I
705 password.0 = I
706 uid.0 = I
707 gid.0 = I
708 loginclass.0= I
709 pwchange.0 = I
710 deact.0 = I
711 gecos.0 = I
712 home.0 = I
713 shell.0 = I
714
715 /* also smbpasswd stems */
716 lmhash. = ''
717 nthash. = ''
718 flags. = ''
719 lct. = ''
720 lmhash.0 = I
721 nthash.0 = I
722 flags.0 = I
723 lct.0 = I
724
725 /* smbusermap stem */
726 MapTo. = ''
727 MapTo.0 = I
728
729 /* our private stem */
730 status.0 = I
731 IF options.!debug == 1 THEN say '_MasterpasswdRead() done, read 'username.0' users'
732return
733
734/*:VRX _MasterpasswdWrite
735*/
736_MasterpasswdWrite:
737 IF options.!debug == 1 THEN say "_MasterpasswdWrite() started"
738 newmasterpasswd = TempDir'master.passwd'
739 ok = SysFileDelete(newmasterpasswd)
740 call lineout newmasterpasswd, '# Created by smbusers Version 'word(VRGet("Main", "Hinttext"),2)
741 call lineout newmasterpasswd, '# syntax:'
742 call lineout newmasterpasswd, '# username:passwd:UID:GID:login-class:chg pw x sec:deact x sec:GECOS:home:shell'
743 do I = 1 to username.0
744 select
745 when Status.I = "DUPLICATE" & settings.!FixErrors then iterate
746 when Status.I = "UID MISMATCH" then do
747 call lineout newmasterpasswd, username.I':'password.I':'word(uid.I,1)':'gid.I':'loginclass.I':'pwchange.I':'deact.I':'gecos.I':'home.I':'shell.I
748 end
749 when Status.I = "UNIX MISSING" & settings.!FixErrors then do
750 call lineout newmasterpasswd, username.I':'password.I':'uid.I':'gid.I':'loginclass.I':'pwchange.I':'deact.I':'gecos.I':'home.I':'shell.I
751 end
752 otherwise call lineout newmasterpasswd, username.I':'password.I':'uid.I':'gid.I':'loginclass.I':'pwchange.I':'deact.I':'gecos.I':'home.I':'shell.I
753 end
754 end
755 ok = stream(newmasterpasswd,'c','close')
756 ok = VRCopyFile( samba.!masterpasswd, samba.!masterpasswd'.bak' )
757 ok = VRCopyFile( newmasterpasswd, samba.!masterpasswd )
758 ok = SysFileDelete(newmasterpasswd)
759 IF options.!debug == 1 THEN say "_MasterpasswdWrite() done"
760return
761
762/*:VRX _MsgYesNo
763*/
764_MsgYesNo:
765 say "_MsgYesNo() started"
766 buttons.0 = 2
767 buttons.1 = NLVGetMessage(6)
768 buttons.2 = NLVGetMessage(7)
769 default = 2
770 buttons.default = NLVGetMessage(7)
771 esc = 2
772 buttons.esc = NLVGetMessage(7)
773 RC = VRMessage( VRWindow(), Msg.Text, Msg.Title,"Q","buttons.",default, esc )
774 say "_MsgYesNo() done, answer "RC
775return RC
776/*:VRX _NLVSetup
777*/
778_NLVSetup:
779 call NLVSetup
780 CALL NLVSetText 'Main', 'Caption', 1
781
782 CALL NLVSetText 'PB_Save', 'Caption', 10
783 CALL NLVSetText 'PB_Refresh', 'Caption', 11
784 CALL NLVSetText 'PB_Exit', 'Caption', 12
785 CALL NLVSetText 'PB_Help', 'Caption', 13
786 CALL NLVSetText 'PB_About', 'Caption', 14
787 CALL NLVSetText 'PB_RPC', 'Caption', 23
788
789 CALL NLVSetText 'PB_Save', 'Hinttext', 123
790 CALL NLVSetText 'PB_Refresh', 'Hinttext', 124
791 CALL NLVSetText 'PB_Exit', 'Hinttext', 125
792 CALL NLVSetText 'PB_Help', 'Hinttext', 126
793 CALL NLVSetText 'PB_About', 'Hinttext', 127
794 CALL NLVSetText 'PB_RPC', 'Hinttext', 128
795
796 CALL NLVSetText 'TAB_1', 'Userdata', 15
797 CALL NLVSetText 'TAB_2', 'Userdata', 16
798 CALL NLVSetText 'TAB_3', 'Userdata', 170
799 CALL NLVSetText 'TAB_4', 'Userdata', 24
800
801 CALL NLVSetText 'TAB_1', 'Hinttext', 28
802 CALL NLVSetText 'TAB_2', 'Hinttext', 29
803 CALL NLVSetText 'TAB_3', 'Hinttext', 170
804 CALL NLVSetText 'TAB_4', 'Hinttext', 30
805
806 CALL NLVSetText 'Page_1', 'Hinttext', 28
807 CALL NLVSetText 'Page_2', 'Hinttext', 29
808 CALL NLVSetText 'Page_3', 'Hinttext', 171
809 CALL NLVSetText 'Page_4', 'Hinttext', 30
810
811 CALL NLVSetText 'CB_SmbOnly', 'Caption', 17
812 CALL NLVSetText 'CB_SmbGroupsOnly', 'Caption', 21
813
814 CALL NLVSetText 'CB_SmbOnly', 'Hinttext', 121
815 CALL NLVSetText 'CB_SmbGroupsOnly', 'Hinttext', 122
816
817 CALL NLVSetText 'Contextmenu_UserDetailView', 'Caption', 118
818 CALL NLVSetText 'Contextmenu_UserSymbolView', 'Caption', 119
819 CALL NLVSetText 'ContextMenu_UserProperties', 'Caption', 120
820 CALL NLVSetText 'ContextMenu_UserAdd', 'Caption', 40
821 CALL NLVSetText 'ContextMenu_UserDel', 'Caption', 50
822
823 CALL NLVSetText 'ContextMenu_UserJoinGroup', 'Caption', 80
824 CALL NLVSetText 'ContextMenu_UserLeaveGroup', 'Caption', 85
825
826 CALL NLVSetText 'Contextmenu_GroupDetailView', 'Caption', 118
827 CALL NLVSetText 'Contextmenu_GroupSymbolView', 'Caption', 119
828 CALL NLVSetText 'ContextMenu_GroupMembers', 'Caption', 89
829 CALL NLVSetText 'ContextMenu_GroupAdd', 'Caption', 70
830 CALL NLVSetText 'ContextMenu_GroupDel', 'Caption', 75
831 CALL NLVSetText 'ContextMenu_GroupMap', 'Caption', 90
832 CALL NLVSetText 'ContextMenu_GroupUnmap','Caption', 95
833 CALL NLVSetText 'ContextMenu_GroupRebuildScript','Caption', 98
834 CALL NLVSetText 'ContextMenu_GroupWellknown','Caption', 92
835
836 CALL NLVSetText 'DT_Policy', 'Caption', 172
837 CALL NLVSetText 'DT_PolValue', 'Caption', 173
838 CALL NLVSetText 'PB_PolReset', 'Caption', 174
839 CALL NLVSetText 'PB_PolUpdate','Caption', 175
840
841 CALL NLVSetText 'CB_FixErrors', 'Caption', 25
842 CALL NLVSetText 'CB_SyncFullName', 'Caption', 26
843 CALL NLVSetText 'CB_SyncPrimGID', 'Caption', 27
844
845
846return
847/*:VRX _OnErrorDisable
848*/
849_OnErrorDisable:
850 ok = VRSet("PB_Save","Enabled",0)
851 ok = VRSet("PB_Refresh","Enabled",0)
852 ok = VRSet("IPB_UserAdd","Enabled",0)
853 ok = VRSet("IPB_UserDel","Enabled",0)
854 ok = VRSet("IPB_UserLeaveGroup","Enabled",0)
855 ok = VRSet("IPB_UserJoinGroup","Enabled",0)
856 ok = VRSet("IPB_GroupAdd","Enabled",0)
857 ok = VRSet("IPB_GroupDel","Enabled",0)
858 ok = VRSet("IPB_GroupMap","Enabled",0)
859 ok = VRSet("IPB_GroupUnmap","Enabled",0)
860return
861
862/*:VRX _ParseCommandLine
863*/
864_ParseCommandLine:
865 IF options.!debug == 1 THEN SAY "_ParseCommandLine() started"
866 CmdLine = VRGet("Application","Commandline")
867 IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"'
868 upCmdLine = translate(CmdLine)
869
870 UserPos = 0
871 UserPos = pos('--USER=',upCmdLine)
872
873 if UserPos > 0 then do
874 IF options.!debug == 1 THEN SAY " --USER switch detected"
875 UserPasswd = translate(word(substr(CmdLine,UserPos+7,),1),'%','|')
876 parse var UserPasswd Credentials.!Username '%' Credentials.!password
877 end
878 else do
879 UserPos = pos('-U ',upCmdLine)
880 If UserPos > 0 then do
881 IF options.!debug == 1 THEN SAY " -U switch detected"
882 UserPasswd = translate(word(substr(CmdLine,UserPos+3,),1),'%','|')
883 parse var UserPasswd Credentials.!Username '%' Credentials.!password
884 end
885 end
886 IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"'
887 IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"'
888
889 IF options.!debug == 1 THEN SAY "_ParseCommandLine() done"
890return
891/*:VRX _PathStrkLIBC
892*/
893_PathStrkLIBC: procedure
894 PathStr = translate(arg(1),'/','\')
895 PathStr = translate(left(PathStr,2),'$',':')||substr(PathStr,3)
896return PathStr
897
898/*:VRX _PathStrOS2
899*/
900_PathStrOS2: procedure
901 PathStr = translate(arg(1),'\','/')
902 PathStr = translate(left(PathStr,2),':','$')||substr(PathStr,3)
903return PathStr
904
905/*:VRX _PoliciesPopulate
906*/
907_PoliciesPopulate:
908 IF options.!debug == 1 THEN say '_PoliciesPopulate() started'
909 say samba.!pdbeditexe' -P -?'DebugLevel' 1>'samba.!msg' 2>'samba.!error
910 address cmd samba.!pdbeditexe' -P -?'DebugLevel' 2>'samba.!error
911
912 do until lines(samba.!error) = 0
913 PolLine = linein(samba.!error)
914say polline
915 select
916 when pos(":",PolLine) > 0 then iterate
917 when pos("!",PolLine) > 0 then iterate
918 otherwise ok = VRMethod("DDCB_Policy","Addstring", PolLine)
919 end
920 end
921 ok = stream(Samba.!error,'c','close')
922 IF options.!debug == 1 THEN say '_PoliciesPopulate() done'
923return
924
925/*:VRX _PolicyGet
926*/
927_PolicyGet:
928 IF options.!debug == 1 THEN say '_PoliciesGet() started'
929 address cmd samba.!pdbeditexe' -P "'arg(1)'" 'DebugLevel' 1>'samba.!msg
930 PolDesc = linein(samba.!msg)
931 PolValue = linein(samba.!msg)
932 ok = stream(Samba.!msg,'c','close')
933
934 parse var PolDesc . ':' PolDesc
935 parse var PolValue . ':' PolValue
936say strip(PolValue)
937say strip(PolDesc)
938 IF options.!debug == 1 THEN say '_PoliciesGet() done'
939return PolValue
940
941/*:VRX _PolicySet
942*/
943_PolicySet:
944 IF options.!debug == 1 THEN say '_PoliciesSet() started'
945 IF options.!debug == 1 THEN say '_PoliciesSet() done'
946return
947
948/*:VRX _Refresh
949*/
950_Refresh:
951 ok = VRSet("Main", 'Pointer', 'Wait' )
952 ok = SysSleep(0.25)
953 call _MasterPasswdRead
954 call _SmbpasswdRead
955 call _SmbUserMapRead
956 call _GroupRead
957 call _SmbGroupsRead
958
959 call _ContainerPopulate
960 call _ContGroupsPopulate
961 ok = VRSet("Main", 'Pointer', '<default>' )
962return
963
964/*:VRX _SambaGetProperties
965*/
966_SambaGetProperties: procedure expose options. samba.
967 IF options.!debug == 1 THEN say '_SambaGetProperties() started'
968 samba.!homes = ""
969
970 /* Read some values from smb.conf into samba. stem */
971 samba.!smbusermap = VRParseFileName(translate(IniGet("username map", "global",samba.!smbconf),'\','/'),'DPNE')
972 if samba.!smbusermap = 0 then samba.!smbusermap = ""
973 IF options.!debug == 1 THEN say ' Samba Usermap = "'samba.!smbusermap'"'
974
975 samba.!homes = VRParseFileName(translate(IniGet("path", "homes",samba.!smbconf),'\','/'),'DP')
976 if samba.!homes = 0 then samba.!homes = ""
977 IF options.!debug == 1 THEN say ' Samba homes = "'samba.!homes'"'
978
979 samba.!profiles = translate(IniGet("path", "profiles",samba.!smbconf),'\','/')
980 if samba.!profiles = 0 then samba.!profiles = ""
981 IF options.!debug == 1 THEN say ' Samba profiles = "'samba.!profiles'"'
982
983 samba.!netlogon = translate(IniGet("path", "netlogon",samba.!smbconf),'\','/')
984 if samba.!netlogon = 0 then samba.!netlogon = ""
985 IF options.!debug == 1 THEN say ' Samba netlogon = "'samba.!netlogon'"'
986
987 IF options.!debug == 1 THEN say '_SambaGetProperties() done'
988return
989
990/*:VRX _SambaShowError
991*/
992_SambaShowError: procedure expose samba. settings. options.
993 if stream(samba.!error,'c','query size') > 0 then do
994 I = 0
995 do while lines(samba.!error) <> 0
996 I = I + 1
997 smberr.I = linein(samba.!error)
998 end
999 smberr.0 = I
1000 Buttons.1 = NLVGetMessage(2)
1001 Buttons.0 = 1
1002 id = VRMessageStem( VRWindow(), "smberr.", VRGet("Main", "Caption") , "Error", "Buttons.", buttons.1, buttons.1 )
1003 end
1004 ok = stream(Samba.!error,"c","close")
1005 ok = SysFileDelete(Samba.!error)
1006return
1007
1008/*:VRX _SambaShowMsg
1009*/
1010_SambaShowMsg: procedure expose samba. settings. options.
1011 if stream(samba.!msg,'c','query size') > 0 then do
1012 skipWords = arg(1)
1013 skip.0 = words(skipWords)
1014 do J = 1 to skip.0
1015 skip.J = translate(word(skipWords,J))
1016 end
1017 I = 0
1018 do while lines(samba.!msg) <> 0
1019 msgline = linein(samba.!msg)
1020 SkipIt = 0
1021 do J = 1 to skip.0
1022 if pos(skip.J,translate(msgline)) > 0 then do
1023 skipit = 1
1024 leave
1025 end
1026 end
1027 if \SkipIt then do
1028 I = I + 1
1029 smbmsg.I = strip(MsgLine)
1030 end
1031 end
1032 smbmsg.0 = I
1033 if smbmsg.0 > 0 then do
1034 Buttons.1 = "OK" /* NLVGetMessage(2) */
1035 Buttons.0 = 1
1036 id = VRMessageStem( VRWindow(), "smbmsg.", VRGet("Main", "Caption") , "I", "Buttons.", buttons.1, buttons.1 )
1037 end
1038 end
1039 ok = stream(Samba.!msg,"c","close")
1040 ok = SysFileDelete(Samba.!msg)
1041return
1042/*:VRX _SetFlag
1043*/
1044_SetFlag: procedure
1045 FlagVar = arg(1)
1046 FlagStatus = arg(2)
1047 FlagType = arg(3)
1048 say FlagVar
1049 if FlagStatus then do
1050 FlagVar = FlagType||translate(FlagVar,' ',FlagType)
1051 end
1052 else do
1053 FlagVar = translate(FlagVar,' ',FlagType)
1054 end
1055 FlagVar = space(FlagVar,0)
1056 say FlagVar
1057return FlagVar
1058
1059/*:VRX _ShowMsg
1060*/
1061_ShowMsg:
1062 Buttons.1 = NLVGetMessage( 2 )
1063 Buttons.0 = 1
1064 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
1065 IF options.!debug == 1 THEN say Msg.Text
1066return
1067
1068/*:VRX _SmbGroupMembersSync
1069*/
1070_SmbGroupMembersSync:
1071 IF options.!debug == 1 THEN say '_SmbGroupMembersSync() started'
1072 CurGID = arg(1)
1073 if datatype(CurGID) = "NUM" then do
1074 CurNTGroupName = ""
1075 do Idx = 1 to GGID.0
1076/* say '"'CurGID'" --- "'GGID.Idx'"' */
1077 if CurGID = GGID.Idx then do
1078 CurNTGroupName = NTGroupName.Idx
1079 CurGroupIdx = Idx
1080 leave
1081 end
1082 end
1083 if CurNTGroupName = "" then do
1084 say "Invalid GID "CurGID
1085 return
1086 end
1087 end
1088 else CurNTGroupName = arg(1)
1089 say samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
1090 address cmd samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
1091 if RC <> 0 then call _SambaShowError
1092 else do
1093 Z = 0
1094 SyncedUsers = ""
1095 do while lines(samba.!msg) <> 0
1096 Z = Z + 1
1097 smbmsg.Z = linein(samba.!msg)
1098 parse var smbmsg.Z WorkGroup'\'User
1099 SyncedUsers = SyncedUsers||User','
1100 end
1101 ok = stream(Samba.!msg,"c","close")
1102 smbmsg.0 = Z
1103 Gusers.CurGroupIdx = SyncedUsers
1104 end
1105 IF options.!debug == 1 THEN say '_SmbGroupMembersSync() done'
1106return
1107
1108/*:VRX _SmbGroupsRead
1109*/
1110_SmbGroupsRead:
1111 IF options.!debug == 1 THEN say '_SmbGroupsRead() started'
1112 groupmap = TempDir'netgroupmap.txt'
1113 ok = SysFileDelete(groupmap)
1114 say ' 'samba.!netexe' groupmap list -l --debuglevel=0 >'groupmap
1115 address cmd samba.!netexe' groupmap list -l --debuglevel=0 >'groupmap
1116
1117 gname.0 = 0
1118 do while lines(groupmap) <> 0
1119 gmline = linein(groupmap)
1120 if left(gmline,1) <> " " then do /* Found group */
1121 gname.0 = gname.0 + 1
1122 smbgname = strip(gmline)
1123 SID = substr(linein(groupmap),14)
1124 UnixGID = substr(linein(groupmap),14)
1125 Unixgroup = substr(linein(groupmap),14)
1126 GroupType = substr(linein(groupmap),14)
1127 GroupComment = substr(linein(groupmap),14)
1128 do I = 1 to Groupname.0
1129 if GGID.I = UnixGID then do
1130 NTGroupname.I = smbgname
1131 SID.I = SID
1132 RID.I = substr(SID,lastpos('-',SID)+1)
1133 NTComment.I = GroupComment
1134 NTGroupType.I = delword(GroupType,words(GroupType))
1135 GStatus.I = 'NOT FOUND' /* we set this FOR all NT groups - the variable is cleared, when an appriate LIBC group exists */
1136 leave
1137 end
1138 end
1139 end
1140 end
1141 ok = stream(groupmap,'c','close')
1142 ok = SysFileDelete(groupmap)
1143
1144 /* Now read the group list */
1145 grouplist = TempDir'netgrouplist.txt'
1146 ok = SysFileDelete(grouplist)
1147 GroupListError = 0
1148 say ' 'samba.!netexe' rpc group -l 'DebugLevel' 'UserCred' 1>'grouplist' 2>'samba.!error
1149 address cmd samba.!netexe' rpc group -l 'DebugLevel' 'UserCred' 1>'grouplist' 2>'samba.!error
1150 if RC <> 0 then do
1151 call _SambaShowError
1152 GroupListError = 1
1153 end
1154
1155 /* Read grouplist */
1156 dummy = linein(grouplist)
1157 dummy = linein(grouplist)
1158 dummy = linein(grouplist)
1159 i = 0
1160 do while lines(grouplist) <> 0
1161 i = i + 1
1162 gline.i = strip(linein(grouplist))
1163 end
1164 ok = stream(grouplist,'c','close')
1165 ok = SysFileDelete(grouplist)
1166
1167 gline.0 = i
1168
1169 do i = 1 to gline.0
1170 ngroup = strip(left(gline.i,22))
1171 ncomment = strip(substr(gline.i,23))
1172 do j=1 to groupname.0
1173 if GStatus.j = "" then iterate
1174 if ngroup = strip(left(NTGroupname.j,21)) then do
1175 nox = 0
1176 GStatus.j = ""
1177 leave
1178 end
1179 end
1180 end
1181
1182 if gname.0 <> gline.0 & GroupListError = 0 then do
1183 Msg.Title= VRGet("Main","Caption")
1184 Msg.Type = "W"
1185 Msg.Text = NLVGetMessage(112, gline.0, gname.0)
1186 call _ShowMsg
1187 end
1188 else IF options.!debug == 1 THEN say ' Samba groups appear to be workable.'
1189
1190 IF options.!debug == 1 THEN say '_SmbGroupsRead() done, 'gline.0' smbgroups read'
1191return
1192/*:VRX _SmbpasswdRead
1193*/
1194_SmbpasswdRead:
1195 IF options.!debug == 1 THEN say '_SmbpasswdRead() started'
1196
1197 /* clear existing stems */
1198 drop sline.
1199 drop sname.
1200
1201 /* create our temporary smbpasswd file */
1202 ok = SysFileDelete(TempDir'smbpasswd.tmp')
1203 address cmd samba.!pdbeditexe' --debuglevel=0 -L -w >'TempDir'smbpasswd.tmp'
1204 ok = SysFileDelete(samba.!smbpasswd)
1205
1206 do while lines(TempDir'smbpasswd.tmp') <> 0
1207 tmpline = linein(TempDir'smbpasswd.tmp')
1208 if pos(':', tmpline) = 0 then iterate
1209 if pos('corrupt', tmpline) > 0 then do
1210 parse var tmpline . 'username 'username' with uid 'uid ' is' .
1211 tmpline = username':'uid':?:?:[?'copies(' ',12)']:?:'
1212 end
1213 call lineout samba.!smbpasswd, tmpline
1214 end
1215 ok = stream(samba.!smbpasswd,'c','close')
1216 ok = stream(TempDir'smbpasswd.tmp','c','close')
1217
1218 ok = SysFileDelete(TempDir'smbpasswd.tmp')
1219
1220 /* Read smbpasswd */
1221 i = 0
1222 err = 0
1223 cmt = 0
1224 do while lines(samba.!smbpasswd) <> 0
1225 i = i + 1
1226 sline.i = strip(linein(samba.!smbpasswd))
1227
1228 select
1229 when left(sline.i,1) = '#' then do
1230 sname.i = '#'
1231 cmt = cmt + 1
1232 end
1233 when pos('UNKNOWN PARAMETER', translate(sline.i)) > 0 then do
1234 sname.i = '#'
1235 err = err + 1
1236 Msg.Title= "Broken "samba.!smbconf
1237 Msg.Text = sline.i
1238 Msg.Type = "E"
1239 call _ShowMsg
1240 end
1241 when pos(':[',translate(sline.i)) > 0 & pos(']:LCT-',translate(sline.i)) > 0 then do
1242 /* we guess a valid smbdpasswd user entry here */
1243 parse var sline.i name':'.
1244 sname.i = translate(name)
1245 /* still something wrong - we got no name, trash this line */
1246 if sname.i = '' then i = i - 1
1247 end
1248 otherwise do
1249 /* if we did not find a valid line in the previous check this line is garbage, likely debug output.. */
1250 i = i - 1
1251 end
1252 end
1253 end
1254
1255 sline.0 = i
1256 sname.0 = i
1257 ok = stream(samba.!smbpasswd,'c','close')
1258
1259 /* list each line in smbpasswd */
1260 do i=1 to sline.0
1261
1262 /* skip comments in smbpasswd */
1263 if sname.i = '#' then iterate
1264
1265 /* parse smbpasswd info */
1266 parse var sline.i name':'uid':'lmhash':'nthash':['flags']:'lct':'
1267 flags = strip(flags)
1268 ucName = translate(name)
1269
1270 /* find matching entry in master.passwd & confirm UIDs match */
1271 ok = 0
1272 bad = 0
1273 nox = 1
1274 do j=1 to username.0
1275 if translate(username.j) = ucName then do
1276 nox = 0
1277 lmhash.j = lmhash
1278 nthash.j = nthash
1279 flags.j = flags
1280 if pos('?',flags.j) > 0 then status.J = "CORRUPT SMB USER"
1281 lct.j = lct
1282 if uid.j = uid | (uid = 0 & uid.j > 65500) then
1283 ok = j
1284 else do
1285 status.j = "UID MISMATCH"
1286 uid.j = uid.j' vs 'uid
1287 end
1288 leave
1289 end
1290 end
1291 if nox then do /* No master.passwd entry found ! */
1292 nx = 1 + username.0
1293 username.0 = nx
1294 password.0 = nx
1295 username.nx = name
1296 uid.nx = uid
1297 gid.nx = uid
1298 password.nx = "*"
1299 loginclass.NX = '' /* dummy value */
1300 pwchange.NX = '0' /* dummy value */
1301 deact.NX = '0' /* dummy value */
1302 gecos.NX = name /* not really appropriate, but better than a dummy value */
1303 home.NX = '/nonexistent' /* dummy value */
1304 shell.NX = '/usr/sbin/nologin' /* dummy value */
1305 lmhash.NX = lmhash
1306 nthash.NX = nthash
1307 flags.NX = flags
1308 lct.NX = lct
1309 Status.nx = 'UNIX MISSING'
1310 /* we must fix this immediately! */
1311 say "WARNING! Missing master.passwd record created using defaults!!!!!!!!!!!!!!!!!"
1312 call _MasterpasswdWrite
1313 call _PasswordDBRewrite
1314 end
1315 end
1316 IF options.!debug == 1 THEN say '_SmbpasswdRead() done, read 'sname.0-cmt-err' Samba users, 'cmt' comments, 'err' errors.'
1317return
1318
1319/*:VRX _SmbUserMapRead
1320*/
1321_SmbUserMapRead:
1322 IF options.!debug == 1 THEN say '_SmbUserMapRead() started'
1323 /* Read complete smbusermap */
1324 I = 0
1325 if samba.!smbusermap <> "" then do
1326 do until lines(samba.!smbusermap) = 0
1327 usermapline = strip(linein(samba.!smbusermap))
1328
1329 /* Skip comments */
1330 if left(usermapline,1) = "#" then iterate
1331 if left(usermapline,1) = ";" then iterate
1332
1333 /* parse fields into stem variables */
1334 I = I + 1
1335 parse var usermapline usermapname.I' = 'usernamemapto.I
1336
1337 do J = 1 to Username.0
1338 if translate(Username.J) = translate(Usermapname.I) then do
1339 MapTo.J = usernamemapto.I
1340 leave
1341 end
1342 end
1343 end
1344 ok = stream(samba.!smbusermap,'c','close')
1345 drop usermapline
1346 drop usermapname.
1347 drop usernamemapto.
1348 IF options.!debug == 1 THEN say '_SmbUserMapRead() done, 'I' user mappings read'
1349 end
1350 else IF options.!debug == 1 THEN say '_SmbUserMapRead() done, not installed'
1351return
1352
1353/*:VRX _SmbUserMapWrite
1354*/
1355_SmbUserMapWrite:
1356 IF options.!debug == 1 THEN say '_SmbUserMapWrite() started'
1357 HaveMappedUser = 0
1358 do I = 1 to MapTo.0
1359 if MapTo.I <> "" then do
1360 HaveMappedUser = 1
1361 leave
1362 end
1363 end
1364 if samba.!smbusermap = "" & HaveMappedUser then do
1365 Msg.Text = NLVGetMessage(110)
1366 Msg.Type = "E"
1367 call _ShowMsg
1368 IF options.!debug == 1 THEN say '_SmbUserMapWrite() done, not installed.'
1369 return
1370 end
1371
1372 if samba.!smbusermap <> "" then do
1373 ok = VRCopyFile( samba.!smbusermap, samba.!smbusermap'.bak' )
1374 ok = SysFileDelete(samba.!smbusermap)
1375 call lineout samba.!smbusermap, '# Created by smbusers Version 'word(VRGet("Main", "Hinttext"),2)
1376 call lineout samba.!smbusermap, '# syntax:'
1377 call lineout samba.!smbusermap, '# Samba username = Windows username'
1378
1379 do I = 1 to MapTo.0
1380 if MapTo.I <> "" then do
1381 call lineout samba.!smbusermap, Username.I' = 'MapTo.I
1382 end
1383 end
1384 ok = stream(samba.!smbusermap,'c','close')
1385 IF options.!debug == 1 THEN say '_SmbUserMapWrite() done'
1386 end
1387 else IF options.!debug == 1 THEN say '_SmbUserMapWrite() done, not installed.'
1388return
1389
1390/*:VRX _SmbUsersList
1391*/
1392_SmbUsersList:
1393
1394userCnt = 0
1395
1396/* list each line in smbpasswd */
1397do i=1 to sline.0
1398
1399 /* skip comments in smbpasswd */
1400 if sname.i = '#' then
1401 iterate
1402
1403 /* parse smbpasswd info */
1404 parse var sline.i name':'uid':'.':'.':'flags':'.
1405 ucName = translate(name)
1406
1407 /* find matching entry in master.passwd & confirm UIDs match */
1408 ok = 0
1409 bad = 0
1410 do j=1 to mname.0
1411 if mname.j = ucName then do
1412 if muid.j = uid | (uid = 0 & muid.j > 65500) then
1413 ok = j
1414 else
1415 bad = j
1416 leave
1417 end
1418 end
1419
1420 /* if there was a match, show all info;
1421 otherwise, show smbpasswd info & an error message */
1422 userCnt = userCnt + 1
1423 RH = VRMethod("CN_Users","AddRecord")
1424
1425 if ok <> 0 then do
1426 parse var mline.ok .':'.':'.':'gid':'.':'.':'.':'full':'home':'.
1427 home = _PathStrOS2(home)
1428 say left(userCnt, 4) substr(flags, 2, 4) left(name, 11) left(uid, 6),
1429 left(gid, 6) left(full, 18) left(home, 23)
1430 flags = strip(substr(flags, 2, 4))
1431 ok = VRMethod("CN_Users","SetFieldData", RH, NrFH, UserCnt, SmbFH, flags, NameFH, Name, UIDFH, Uid, GIdFH, GID, FullNameFH, full, HomeFH, Home)
1432 end
1433 else do
1434 if bad <> 0 then
1435 error = "* UID should be '" || muid.bad || "' - use 'Change' to fix *"
1436 else
1437 error = "* Unix-user not found - use 'Change' to fix *"
1438 say left(userCnt, 4) substr(flags, 2, 4) left(name, 11) left(uid, 6),
1439 left(error, 50)
1440 flags = strip(substr(flags, 2, 4))
1441 ok = VRMethod("CN_Users","SetFieldData", RH, SCommentFH, error)
1442 ok = VRMethod("CN_Users","SetFieldData", RH, NrFH, UserCnt, SmbFH, flags, NameFH, Name, UIDFH, Uid )
1443 end
1444
1445
1446end
1447
1448if userCnt = 0 then
1449 say " * No Samba users have been defined - use the 'Add' command * "
1450
1451return
1452
1453/*:VRX _useraddsmb
1454*/
1455_useraddsmb:
1456 IF options.!debug == 1 THEN say '_UserAddSmb() started'
1457 select
1458 when VRGet("CB_MachineAccount","Set") then do
1459 say ' 'samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -m'
1460 address cmd samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -m 2>'samba.!error' 1>'samba.!msg
1461 smbpasswdrc = rc
1462 if rc <> 0 then call _SambaShowError
1463 else call _SambaShowMsg
1464 end
1465 when VRGet("CB_NoPassword","Set") then do
1466 say ' 'samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -n'
1467 address cmd samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -n 2>'samba.!error' 1>'samba.!msg
1468 smbpasswdrc = rc
1469 if rc <> 0 then call _SambaShowError
1470 else call _SambaShowMsg
1471 end
1472 otherwise do
1473 pwdfile = TempDir'newpwd'
1474 call lineout pwdfile, VRGet("EF_Password","value")
1475 call lineout pwdfile, VRGet("EF_Password","value")
1476 ok = stream(pwdfile,"c","close")
1477 say ' 'samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -s <'pwdfile' 2>'samba.!error
1478 address cmd samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -s <'pwdfile' 2>'samba.!error' 1>'samba.!msg
1479 smbpasswdrc = rc
1480 if rc <> 0 then call _SambaShowError
1481 else call _SambaShowMsg
1482 if swatauth & VRGet("CB_Swat_Allowed","set") then do
1483 if VRFileExists(swatusers) then cFlag = ""; else cFlag="c"
1484 say ' 'samba.!htpasswdexe' -b "'swatusers'" 'VRGet("EF_Username","Value")' 'copies("*",length(VRGet("EF_Password","value")))
1485 address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" 'VRGet("EF_Username","Value")' 'VRGet("EF_Password","value")' 2>'samba.!error' 1>'samba.!msg
1486 if rc <> 0 then call _SambaShowError
1487 else call _SambaShowMsg
1488 end
1489 ok = SysFileDelete(pwdfile)
1490 end
1491 end
1492 IF options.!debug == 1 THEN say '_UserAddSmb() done'
1493return
1494
1495/*:VRX _UserIsValid
1496*/
1497_UserIsValid: procedure expose username.
1498 User = arg(1)
1499 HaveValidUser = 0
1500 do I = 1 to username.0
1501 if translate(username.I) = translate(User) then do
1502 HaveValiduser = 1
1503 leave
1504 end
1505 end
1506return HaveValidUser
1507
1508/*:VRX _UserPropertiesGet
1509*/
1510_UserPropertiesGet:
1511 IF options.!debug == 1 THEN say '_UserPropertiesGet() started'
1512 CurUser = arg(1)
1513
1514 /* "up" hier drin heiát UserProperties */
1515
1516 UserProperties = TempDir'UserProperties.txt'
1517 ok = SysFileDelete(UserProperties)
1518
1519 IF options.!debug == 1 THEN say ' 'samba.!pdbeditexe' 'CurUser' -L -v 'debuglevel
1520 address cmd samba.!pdbeditexe' 'CurUser' -L -v 'DebugLevel' >'UserProperties
1521
1522 /* Read user properties */
1523 i = 0
1524 do while lines(UserProperties) <> 0
1525 i = i + 1
1526 upline.i = strip(linein(UserProperties))
1527 end
1528 ok = stream(UserProperties,'c','close')
1529 ok = SysFileDelete(UserProperties)
1530
1531 upline.0 = i
1532
1533 ok = VRSet("CN_UserProperties","Painting", 0 )
1534 ok = VRMethod("CN_UserProperties","RemoveRecord","ALL")
1535 do i = 1 to upline.0
1536 parse var upline.i uptype.i ':' upvalue.i
1537 uptype.i = strip(uptype.i)
1538 upvalue.i = strip(upvalue.i)
1539 CurType = translate(uptype.i)
1540 /* say CurType */
1541 select
1542 when CurType = "DOMAIN" then upCommand.i = "--domain="
1543 when CurType = "PROFILE PATH" then upCommand.i = "--profile="
1544 when CurType = "ACCOUNT DESC" then upCommand.i = "--account-desc="
1545 when CurType = "FULL NAME" then upCommand.i = "--fullname="
1546 when CurType = "LOGON SCRIPT" then upCommand.i = "--script="
1547 when CurType = "HOME DIRECTORY" then upCommand.i = "--homedir="
1548 when CurType = "HOMEDIR DRIVE" then upCommand.i = "--drive="
1549 /* when CurType = "ACCOUNT FLAGS" then upCommand.i = '-c "[NDHLX]"' */
1550 when CurType = "PRIMARY GROUP SID" then do
1551 upCommand.i = ""
1552 if Settings.!SyncPrimGID = 1 & \(translate(Username.CurUserNr) = "GUEST"|translate(Username.CurUserNr) = "NOBODY") then do
1553 NewPrimGID = substr(upvalue.i,lastpos('-',upvalue.i)+1,)
1554 IF options.!debug == 1 THEN say " NewPrimGID = "NewPrimGID
1555 If GID.CurUserNr <> NewPrimGID then do
1556 GID.CurUserNr = NewPrimGID
1557 IF options.!debug == 1 THEN say " Synced Primary GID!"
1558 SyncedPrimGID = 1
1559 end
1560 end
1561 end
1562
1563 otherwise upCommand.i = ""
1564 end
1565 uprh.i = VRMethod("CN_UserProperties","AddRecord")
1566 ok = VRMethod("CN_UserProperties","SetFieldData", uprh.i, upNrFH, i, upTypeFH, uptype.i, upValueFH, upValue.i, upCommandFH, upCommand.i )
1567 NotHaveCommand = (upCommand.i = "")
1568 ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "ReadOnly", NotHaveCommand)
1569 if VRGet("CB_EditableFieldsOnly","Set") then ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "Visible", \NotHaveCommand)
1570 select
1571 when CurType = "ACCOUNT FLAGS" then do
1572 /* ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "Visible", 0) */
1573 parse var upvalue.I '['CurFlags']'
1574 if pos("U", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Regular user account")
1575 if pos("T", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Temporary duplicate of other account")
1576 if pos("M", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "MNS logon user account")
1577 if pos("W", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Workstation Trust Account")
1578 if pos("S", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Server Trust Account")
1579 if pos("I", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Domain Trust Account")
1580
1581 ok = VRSet("CB_upNoPassword", "Set", (pos("N",CurFlags) > 0))
1582 call CB_upNoPassword_Click
1583 ok = VRSet("CB_upPassword_doesnt_expire", "Set", (pos("X",CurFlags) > 0))
1584 ok = VRSet("CB_upDeactivated", "Set", (pos("D",CurFlags) > 0))
1585 end
1586 when right(CurType,8) = "USERNAME" then do
1587 ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "Visible", 0)
1588 ok = VRSet("UserProperties", "caption", NLVGetMessage(120)' "'Username.CurUserNr'"')
1589 end
1590 otherwise nop
1591 end
1592 end
1593 if SwatAuth then do
1594 ok = VRSet("CB_upSWAT_Allowed","Enabled",0)
1595 ok = VRSet("CB_upSWAT_Allowed","set",0)
1596 swatchanged = 0
1597 if VRFileExists(swatusers) then do
1598 do until lines(swatusers) = 0
1599 swatline = linein(swatusers)
1600 parse var swatline curswatuser ':' curswatpw
1601 if curswatuser = CurUser then do
1602 ok = VRSet("CB_upSWAT_Allowed","set",1)
1603 leave
1604 end
1605 end
1606 ok = stream(swatusers,'c','close')
1607 end
1608 end
1609 ok = VRSet("CN_UserProperties","Painting", 1 )
1610 IF options.!debug == 1 THEN say '_UserPropertiesGet() done'
1611return
1612
1613/*:VRX _UserRecWriteBackToStems
1614*/
1615_UserRecWriteBackToStems:
1616 Cur = VRMethod("CN_Users","GetFieldData", RH, NrFH)
1617 Username.Cur = VRMethod("CN_Users","GetFieldData", RH, UsernameFH)
1618 UID.Cur = VRMethod("CN_Users","GetFieldData", RH, UIDFH)
1619 GID.Cur = VRMethod("CN_Users","GetFieldData", RH, GIDFH)
1620 GECOS.Cur = VRMethod("CN_Users","GetFieldData", RH, GECOSFH)
1621 Home.Cur = _PathStrkLIBC(VRMethod("CN_Users","GetFieldData", RH, HomeFH))
1622 Shell.Cur = VRMethod("CN_Users","GetFieldData", RH, ShellFH)
1623 MapTo.Cur = VRMethod("CN_Users","GetFieldData", RH, MapToFH)
1624
1625 if Settings.!SyncFullName = 1 & flags.Cur <> "" then do
1626 call PB_Save_Click
1627 say samba.!pdbeditexe' --user='Username.Cur' --modify --fullname="'GECOS.Cur'" 'DebugLevel' 2>'samba.!error
1628 address cmd samba.!pdbeditexe' --user='Username.Cur' --modify --fullname="'GECOS.Cur'" 'DebugLevel' 2>'samba.!error
1629 if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */
1630 end
1631 /* These are not editable/visible xpwFH, password.i,xlcFH,LoginClass.I,xcpwFH, pwchange.I,xDeactFH, deact.I, Status.I ) */
1632
1633 /* smbpasswd fields */
1634 /* we do not allow editing these
1635 FLagsFH, flags.I, LMHashFH, LMHash.I,NTHashFH, NTHash.I, LCTFH, LCT.I)
1636 */
1637return
1638
1639/*:VRX About_Close
1640*/
1641About_Close:
1642 call About_Fini
1643return
1644
1645/*:VRX About_Create
1646*/
1647About_Create:
1648 call About_Init
1649 ok = VRSet("About","Caption", NLVGetMessage(127))
1650 ok = VRSet("PB_AboutOK","Caption", NLVGetMessage(2))
1651 SambaTeam.0 = 8
1652 SambaTeam.1 = 'Paul Smedley'
1653 SambaTeam.2 = 'Yuri Dario'
1654 SambaTeam.3 = 'Herwig Bauernfeind'
1655 SambaTeam.4 = 'Silvan Scherrer'
1656 SambaTeam.5 = 'Alex Taylor'
1657 SambaTeam.6 = 'Nikolay Kolosov'
1658 SambaTeam.7 = 'All the Samba people'
1659 SambaTeam.8 = 'All the netlabs people'
1660 ok = VRSet("About","Font", VRGet("Page_4","Font"))
1661 ok = VRMethod("LB_SambaTeam","AddStringList", "SambaTeam." )
1662 ok = VRSet("DT_SambaTeam","Caption", NLVGetMessage(129))
1663 ok = VRSet("MLE_Version","Value", NLVGetMessage(1)||'0D0A'x||VRGet("Main", "Hinttext")||'0D0A'x||'0D0A'x||SambaVer)
1664return
1665
1666/*:VRX About_Fini
1667*/
1668About_Fini:
1669 window = VRInfo( "Window" )
1670 call VRDestroy window
1671 drop window
1672return
1673/*:VRX About_Init
1674*/
1675About_Init:
1676 window = VRInfo( "Object" )
1677 if( \VRIsChildOf( window, "Notebook" ) ) then do
1678 call VRMethod window, "CenterWindow"
1679 call VRSet window, "Visible", 1
1680 call VRMethod window, "Activate"
1681 end
1682 drop window
1683return
1684
1685/*:VRX Activate
1686*/
1687Activate:
1688 parse arg Nr
1689 call PushbackAll
1690 CurrentPageNr = Nr
1691 /* ok = VRSet("PB_"Nr,"Font","9.WarpSans Bold") */
1692 ok = VRSet("TAB_"Nr,"Top", TabTop-8)
1693 ok = VRSet("TAB_"Nr,"Left",TabWidth*(Nr-1)+PageLeft)
1694 ok = VRSet("TAB_"Nr,"PicturePath", "#1"||Nr||";#1"||Nr)
1695 ok = VRset("DT_PageName", "Caption", VRGet("TAB_"Nr, "UserData"))
1696 ok = VRSet("Page_"Nr,"Visible", 1)
1697 select
1698 when Nr = 1 then ok = VRSet("IPB_paper","PicturePath","#4;#4")
1699 when Nr = Pages then ok = VRSet("IPB_paper","PicturePath","#6;#6")
1700 otherwise ok = VRSet("IPB_paper","PicturePath","#5;#5")
1701 end
1702return
1703
1704/*:VRX AddGroup_Close
1705*/
1706AddGroup_Close:
1707 call AddGroup_Fini
1708return
1709
1710/*:VRX AddGroup_Create
1711*/
1712AddGroup_Create:
1713 call AddGroup_Init
1714 CALL NLVSetText 'AddGroup', 'Caption', 70
1715 CALL NLVSetText 'PB_GroupAddOK', 'Caption', 2
1716 CALL NLVSetText 'PB_GroupAddCancel', 'Caption', 3
1717 CALL NLVSetText 'DT_GroupName', 'Caption', 71
1718 CALL NLVSetText 'DT_Comment', 'Caption', 72
1719 CALL NLVSetText 'CB_UnixGroupOnly', 'Caption', 73
1720 CALL NLVSetText 'CB_AutomaticGGID', 'Caption', 74
1721 UnixGroupOnly = 0
1722return
1723
1724/*:VRX AddGroup_Fini
1725*/
1726AddGroup_Fini:
1727 window = VRInfo( "Window" )
1728 call VRDestroy window
1729 drop window
1730return
1731/*:VRX AddGroup_Init
1732*/
1733AddGroup_Init:
1734 window = VRInfo( "Object" )
1735 if( \VRIsChildOf( window, "Notebook" ) ) then do
1736 call VRMethod window, "CenterWindow"
1737 call VRSet window, "Visible", 1
1738 call VRMethod window, "Activate"
1739 end
1740 drop window
1741return
1742
1743/*:VRX AddUser_Close
1744*/
1745AddUser_Close:
1746 call AddUser_Fini
1747return
1748
1749/*:VRX AddUser_Create
1750*/
1751AddUser_Create:
1752 call AddUser_Init
1753 CALL NLVSetText 'AddUser', 'Caption', 40
1754
1755 Msg.Title = VRGet("AddUser","Caption")
1756 CALL NLVSetText 'DT_Username', 'Caption', 41
1757 CALL NLVSetText 'DT_GECOS', 'Caption', 42
1758 CALL NLVSetText 'DT_Password_Repeat', 'Caption', 43
1759 CALL NLVSetText 'DT_GID', 'Caption', 44
1760 CALL NLVSetText 'DT_Home', 'Caption', 140
1761 CALL NLVSetText 'DT_Description', 'Caption', 52
1762 CALL NLVSetText 'CB_Must_change_password', 'Caption', 46
1763 CALL NLVSetText 'CB_Cannot_change_password','Caption', 47
1764 CALL NLVSetText 'CB_Password_doesnt_expire', 'Caption', 48
1765 CALL NLVSetText 'CB_Deactivated', 'Caption', 49
1766 CALL NLVSetText 'CB_NoHome', 'Caption', 9
1767
1768 CALL NLVSetText 'PB_AddUserOK', 'Caption', 2
1769 CALL NLVSetText 'PB_AddUserCancel', 'Caption', 3
1770 CALL NLVSetText 'CB_UnixUserOnly', 'Caption', 18
1771 CALL NLVSetText 'CB_MachineAccount', 'Caption', 19
1772 CALL NLVSetText 'CB_NoPassword', 'Caption', 20
1773 CALL NLVSetText 'DT_Password', 'Caption', 33
1774 CALL NLVSetText 'CB_SWAT_Allowed', 'Caption', 35
1775
1776 ok = VRSet("CB_SWAT_Allowed","enabled",Swatauth)
1777
1778 MinPWLength = _PolicyGet("min password length")
1779
1780 if IsUnixUser then do
1781 ok = VRSet("EF_Username","value", Username.SelNr)
1782 call EF_Username_LostFocus
1783 ok = VRMethod("EF_GECOS","SetFocus")
1784 end
1785 else do
1786 NextUID = _GetNextUID()
1787 ok = VRSet("DT_UID","Caption", "UID: "NextUID)
1788 ok = VRSet("DDCB_GID","Value", NextUID)
1789 do I = 1 to GGID.0
1790 if GGID.I = "513" then do
1791 ok = VRSet("DDCB_GID","Value", "513")
1792 leave
1793 end
1794 end
1795 ok = VRMethod( "DDCB_GID", "Reset")
1796 ok = VRMethod( "DDCB_GID", "AddString", NextUID)
1797 ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.")
1798 ok = VRSet("EF_Home", "Value", Samba.!Homes'\')
1799 call EF_Home_Change
1800 end
1801 SecondStage = 0
1802return
1803
1804/*:VRX AddUser_Fini
1805*/
1806AddUser_Fini:
1807 window = VRInfo( "Window" )
1808 call VRDestroy window
1809 drop window
1810return
1811/*:VRX AddUser_Init
1812*/
1813AddUser_Init:
1814 window = VRInfo( "Object" )
1815 if( \VRIsChildOf( window, "Notebook" ) ) then do
1816 call VRMethod window, "CenterWindow"
1817 call VRSet window, "Visible", 1
1818 call VRMethod window, "Activate"
1819 end
1820 drop window
1821return
1822
1823/*:VRX CB_AutomaticGGID_Click
1824*/
1825CB_AutomaticGGID_Click:
1826 ok = VRSet("EF_GGID","Enabled", \VRget("CB_AutomaticGGID","Set"))
1827 if \VRget("CB_AutomaticGGID","Set") then ok = VRSet("EF_GGID","BackColor","<default>")
1828 else ok = VRSet("EF_GGID","BackColor","PaleGray")
1829return
1830
1831/*:VRX CB_Cannot_change_password_Click
1832*/
1833CB_Cannot_change_password_Click:
1834 SecondStage = (SecondStage | VRGet("CB_Cannot_change_password","set"))
1835return
1836
1837/*:VRX CB_Deactivated_Click
1838*/
1839CB_Deactivated_Click:
1840 SecondStage = (SecondStage | VRGet("CB_Deactivated","set"))
1841return
1842
1843/*:VRX CB_Debug_Click
1844*/
1845CB_Debug_Click:
1846 options.!Debug = VRGet("CB_Debug","set")
1847 if options.!Debug then ok = VRREdirectStdIO("ON")
1848 else ok = VRREdirectStdIO("OFF")
1849return
1850
1851/*:VRX CB_EditableFieldsOnly_Click
1852*/
1853CB_EditableFieldsOnly_Click:
1854 call _UserPropertiesGet Username.CurUserNr
1855return
1856
1857/*:VRX CB_FixErrors_Click
1858*/
1859CB_FixErrors_Click:
1860 settings.!FixErrors = VRGet("CB_FixErrors","set")
1861return
1862
1863/*:VRX CB_MachineAccount_Click
1864*/
1865CB_MachineAccount_Click:
1866 if right(VRGet("EF_Username","Value"),1) = "$" then do
1867 /* ok = VRSet("EF_Username","Value",translate(VRGet("EF_Username","Value"))) */
1868 ok = VRset("CB_UnixUserOnly","set", 0)
1869 ok = VRset("CB_MachineAccount","set", 1)
1870 ok = VRSet("CB_NoPassword","set", 0)
1871 ok = VRSet("CB_NoPassword","Enabled", 0)
1872 ok = VRSet("EF_Password","BackColor", "PaleGray")
1873 ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray")
1874 ok = VRSet("EF_Password","Enabled", 0)
1875 ok = VRSet("EF_Password_Repeat","Enabled", 0)
1876 ok = VRSet("CB_Must_Change_Password","Enabled", 0)
1877 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1878 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1879
1880 end
1881 else do
1882 ok = VRset("CB_MachineAccount","set", 0)
1883 ok = VRSet("CB_NoPassword","Enabled", 1)
1884 call CB_NoPassword_Click
1885 end
1886return
1887
1888/*:VRX CB_Must_change_password_Click
1889*/
1890CB_Must_change_password_Click:
1891 SecondStage = (SecondStage | VRGet("CB_Must_change_password","set"))
1892 if VRGet("CB_Must_Change_Password","set") then do
1893 ok = VRSet("CB_Cannot_change_password","Set", 0)
1894 ok = VRSet("CB_Password_doesnt_expire","Set", 0)
1895 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1896 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1897 end
1898 else do
1899 ok = VRSet("CB_Cannot_change_password","Enabled", 1)
1900 ok = VRSet("CB_Password_doesnt_expire","Enabled", 1)
1901 end
1902return
1903
1904/*:VRX CB_NoHome_Click
1905*/
1906CB_NoHome_Click:
1907 ok = VRSet("EF_Home","Enabled",\VRGet("CB_NoHome","set"))
1908 ok = VRset("PB_CreateHome","Enabled",\VRGet("CB_NoHome","set"))
1909 ok = VRSet("PB_ChooseHome","Enabled",\VRGet("CB_NoHome","set"))
1910 if VRGet("CB_NoHome","set") then ok = VRSet("EF_HOME","Value", "\nonexistent")
1911return
1912
1913/*:VRX CB_NoPassword_Click
1914*/
1915CB_NoPassword_Click:
1916 if VRGet("CB_NoPassword","set") then do
1917 ok = VRSet("EF_Password","BackColor", "PaleGray")
1918 ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray")
1919 ok = VRSet("EF_Password","Enabled", 0)
1920 ok = VRSet("EF_Password_Repeat","Enabled", 0)
1921 ok = VRSet("CB_Must_Change_Password","Enabled", 0)
1922 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1923 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1924 ok = VRSet("CB_SWAT_Allowed","Enabled", 0)
1925 end
1926 else do
1927 ok = VRSet("EF_Password","BackColor", "<default>")
1928 ok = VRSet("EF_Password_Repeat","BackColor", "<default>")
1929 ok = VRSet("EF_Password","Enabled", 1)
1930 ok = VRSet("EF_Password_Repeat","Enabled", 1)
1931 ok = VRSet("CB_Must_Change_Password","Enabled", 1)
1932 ok = VRSet("CB_Cannot_change_password","Enabled", 1)
1933 ok = VRSet("CB_Password_doesnt_expire","Enabled", 1)
1934 ok = VRSet("CB_SWAT_Allowed","Enabled", 1)
1935 end
1936return
1937
1938/*:VRX CB_Password_doesnt_expire_Click
1939*/
1940CB_Password_doesnt_expire_Click:
1941 SecondStage = (SecondStage | VRGet("CB_Password_doesnt_expire","set"))
1942return
1943
1944/*:VRX CB_SmbGroupsOnly_Click
1945*/
1946CB_SmbGroupsOnly_Click:
1947 settings.!SmbGroupsOnly = VRGet("CB_SmbGroupsOnly","Set")
1948 call _ContGroupsPopulate
1949return
1950
1951/*:VRX CB_SmbOnly_Click
1952*/
1953CB_SmbOnly_Click:
1954 settings.!SmbOnly = VRGet("CB_SmbOnly","Set")
1955 call _ContainerPopulate
1956return
1957
1958/*:VRX CB_SWAT_Allowed_Click
1959*/
1960CB_SWAT_Allowed_Click:
1961 if right(VRGet("EF_Username","Value"),1) = "$" then do
1962 /* ok = VRSet("EF_Username","Value",translate(VRGet("EF_Username","Value"))) */
1963 ok = VRset("CB_UnixUserOnly","set", 0)
1964 ok = VRset("CB_MachineAccount","set", 1)
1965 ok = VRSet("CB_NoPassword","set", 0)
1966 ok = VRSet("CB_NoPassword","Enabled", 0)
1967 ok = VRSet("EF_Password","BackColor", "PaleGray")
1968 ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray")
1969 ok = VRSet("EF_Password","Enabled", 0)
1970 ok = VRSet("EF_Password_Repeat","Enabled", 0)
1971 ok = VRSet("CB_Must_Change_Password","Enabled", 0)
1972 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1973 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1974
1975 end
1976 else do
1977 ok = VRset("CB_MachineAccount","set", 0)
1978 ok = VRSet("CB_NoPassword","Enabled", 1)
1979 call CB_NoPassword_Click
1980 end
1981return
1982
1983/*:VRX CB_SyncFullName_Click
1984*/
1985CB_SyncFullName_Click:
1986 settings.!SyncFullName = VRGet("CB_SyncFullName","set")
1987return
1988
1989/*:VRX CB_SyncPrimGID_Click
1990*/
1991CB_SyncPrimGID_Click:
1992 settings.!SyncPrimGID = VRGet("CB_SyncPrimGID","set")
1993return
1994
1995/*:VRX CB_UnixGroupOnly_Click
1996*/
1997CB_UnixGroupOnly_Click:
1998 UnixGroupOnly = VRGet("CB_UnixGroupOnly","set")
1999 ok = VRSet("EF_Comment","Enabled", \VRget("CB_UnixGroupOnly","Set"))
2000 if \VRget("CB_UnixGroupOnly","Set") then ok = VRSet("EF_Comment","BackColor","<default>")
2001 else ok = VRSet("EF_Comment","BackColor","PaleGray")
2002return
2003
2004/*:VRX CB_UnixUserOnly_Click
2005*/
2006CB_UnixUserOnly_Click:
2007 if VRGet("CB_UnixUserOnly","set") then do
2008 ok = VRSet("CB_NoPassword","set",1)
2009 call CB_NoPassword_Click
2010 ok = VRSet("EF_Description", "BackColor", "PaleGray")
2011 ok = VRSet("EF_Description", "Enabled", 0)
2012 end
2013 else do
2014 ok = VRSet("EF_Description", "BackColor", "<default>")
2015 ok = VRSet("EF_Description", "Enabled", 1)
2016 ok = VRSet("CB_NoPassword","set",0)
2017 call CB_NoPassword_Click
2018 end
2019return
2020
2021/*:VRX CB_upCannot_change_password_Click
2022*/
2023CB_upCannot_change_password_Click:
2024
2025return
2026
2027/*:VRX CB_upDeactivated_Click
2028*/
2029CB_upDeactivated_Click:
2030 CurFlags = _SetFlag(CurFlags, VRGet("CB_upDeactivated","set"), 'D')
2031return
2032
2033/*:VRX CB_upMust_change_password_Click
2034*/
2035CB_upMust_change_password_Click:
2036
2037return
2038
2039/*:VRX CB_upNoPassword_Click
2040*/
2041CB_upNoPassword_Click:
2042 CurFlags = _SetFlag(CurFlags, VRGet("CB_upNoPassword","set"), 'N')
2043 if VRGet("CB_upNoPassword","set") then do
2044 ok = VRSet("EF_upPassword","value","")
2045 ok = VRSet("EF_upPassword_Repeat","value","")
2046 ok = VRSet("DT_upPassword","Enabled",0)
2047 ok = VRSet("DT_upPassword_Repeat","Enabled",0)
2048 ok = VRSet("EF_upPassword","Enabled",0)
2049 ok = VRSet("EF_upPassword_Repeat","Enabled",0)
2050 ok = VRSet("EF_upPassword","BackColor", "PaleGray")
2051 ok = VRSet("EF_upPassword_Repeat","BackColor", "PaleGray")
2052 end
2053 else do
2054 ok = VRSet("DT_upPassword","Enabled",1)
2055 ok = VRSet("DT_upPassword_Repeat","Enabled",1)
2056 ok = VRSet("EF_upPassword","Enabled",1)
2057 ok = VRSet("EF_upPassword_Repeat","Enabled",1)
2058 ok = VRSet("EF_upPassword","BackColor", "<default>")
2059 ok = VRSet("EF_upPassword_Repeat","BackColor", "<default>")
2060 end
2061return
2062
2063/*:VRX CB_upPassword_doesnt_expire_Click
2064*/
2065CB_upPassword_doesnt_expire_Click:
2066 CurFlags = _SetFlag(CurFlags, VRGet("CB_upPassword_doesnt_expire","set"), 'X')
2067return
2068
2069/*:VRX CB_upSWAT_Allowed_Click
2070*/
2071CB_upSWAT_Allowed_Click:
2072 swatchanged = 1
2073return
2074
2075/*:VRX CN_Groups_ContextMenu
2076*/
2077CN_Groups_ContextMenu:
2078 if VRInfo("Top") < 1325 & VRGet("CN_Groups", "View") = "Detail" then call _ColumnsMenu "CN_Groups"
2079 else ok = VRMethod( "Contextmenu_Group", "Popup", , , "", "PositionOnItem" )
2080return
2081
2082/*:VRX CN_Groups_DoubleClick
2083*/
2084CN_Groups_DoubleClick:
2085 call Contextmenu_GroupMembers_Click
2086return
2087
2088/*:VRX CN_Groups_EndEdit
2089*/
2090CN_Groups_EndEdit:
2091call beep 880, 20
2092 GRH = VRInfo("Record")
2093
2094 /* write back all editable field to the stems */
2095 call _GroupRecWritebackToStems
2096
2097return
2098
2099/*:VRX CN_UserProperties_BeginEdit
2100*/
2101CN_UserProperties_BeginEdit:
2102 drop NewupValue
2103 drop OldupValue
2104 upRH = VRInfo("Record")
2105 OldupValue = VRMethod("CN_UserProperties","GetFieldData", upRH, upValueFH)
2106 say OldupValue
2107return
2108
2109/*:VRX CN_UserProperties_EndEdit
2110*/
2111CN_UserProperties_EndEdit:
2112 upRH = VRInfo("Record")
2113 NewupValue = VRMethod("CN_UserProperties","GetFieldData", upRH, upValueFH)
2114 say NewupValue
2115 if OldUpValue <> NewupValue then do
2116 newcommand = newcommand||' 'VRMethod("CN_UserProperties","GetFieldData", upRH,upCommandFH)||'"'NewupValue'"'
2117 say "New command: "newcommand
2118 end
2119return
2120
2121/*:VRX CN_Users_ContextMenu
2122*/
2123CN_Users_ContextMenu:
2124 if VRInfo("Top") < 1325 & VRGet("CN_users", "View") = "Detail" then call _ColumnsMenu "CN_users"
2125 else do
2126 RH = VRInfo("Record")
2127 if RH <> "" then do
2128 CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH)
2129 ok = VRset("Contextmenu_UserProperties", "Enabled", (CurFlags <> ""))
2130 ok = VRMethod( "Contextmenu_user", "Popup", , , "", "PositionOnItem" )
2131 end
2132 end
2133return
2134
2135/*:VRX CN_Users_DoubleClick
2136*/
2137CN_Users_DoubleClick:
2138 say 'CN_Users_DoubleClick() started'
2139 RH = VRInfo("Record")
2140 CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH)
2141 if CurFlags <> "" then window = VRLoadSecondary( "UserProperties", "W" )
2142 say 'CN_Users_DoubleClick() done'
2143return
2144
2145/*:VRX CN_Users_EndEdit
2146*/
2147CN_Users_EndEdit:
2148 call beep 880, 20
2149 RH = VRInfo("Record")
2150
2151 /* write back all editable field to the stems */
2152 call _UserRecWritebackToStems
2153return
2154
2155/*:VRX Columns_01_Click
2156*/
2157Columns_01_Click:
2158 call _ColumnShow
2159return
2160
2161/*:VRX Columns_02_Click
2162*/
2163Columns_02_Click:
2164 call _ColumnShow
2165return
2166
2167/*:VRX Columns_03_Click
2168*/
2169Columns_03_Click:
2170 call _ColumnShow
2171return
2172
2173/*:VRX Columns_04_Click
2174*/
2175Columns_04_Click:
2176 call _ColumnShow
2177return
2178
2179/*:VRX Columns_05_Click
2180*/
2181Columns_05_Click:
2182 call _ColumnShow
2183return
2184
2185/*:VRX Columns_06_Click
2186*/
2187Columns_06_Click:
2188 call _ColumnShow
2189return
2190
2191/*:VRX Columns_07_Click
2192*/
2193Columns_07_Click:
2194 call _ColumnShow
2195return
2196
2197/*:VRX Columns_08_Click
2198*/
2199Columns_08_Click:
2200 call _ColumnShow
2201return
2202
2203/*:VRX Columns_09_Click
2204*/
2205Columns_09_Click:
2206 call _ColumnShow
2207return
2208
2209/*:VRX Columns_10_Click
2210*/
2211Columns_10_Click:
2212 call _ColumnShow
2213return
2214
2215/*:VRX Columns_11_Click
2216*/
2217Columns_11_Click:
2218 call _ColumnShow
2219return
2220
2221/*:VRX Columns_12_Click
2222*/
2223Columns_12_Click:
2224 call _ColumnShow
2225return
2226
2227/*:VRX Columns_13_Click
2228*/
2229Columns_13_Click:
2230 call _ColumnShow
2231return
2232
2233/*:VRX Columns_14_Click
2234*/
2235Columns_14_Click:
2236 call _ColumnShow
2237return
2238
2239/*:VRX Columns_15_Click
2240*/
2241Columns_15_Click:
2242 call _ColumnShow
2243return
2244
2245/*:VRX Columns_16_Click
2246*/
2247Columns_16_Click:
2248 call _ColumnShow
2249return
2250
2251/*:VRX Columns_17_Click
2252*/
2253Columns_17_Click:
2254 call _ColumnShow
2255return
2256
2257/*:VRX Contextmenu_GroupAdd_Click
2258*/
2259Contextmenu_GroupAdd_Click:
2260 window = VRLoadSecondary( "AddGroup", "W" )
2261return
2262
2263/*:VRX Contextmenu_GroupDel_Click
2264*/
2265Contextmenu_GroupDel_Click:
2266 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2267 if SelGRH.0 = 0 then return
2268 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2269say 'Selected Group Nr = ' SelGNr
2270 Msg.Title = NLVGetMessage(75)
2271 Msg.Type = "Q"
2272 Msg.Text = NLVGetMessage(76,Groupname.SelGNr,NTGroupname.SelGNr,GGID.SelGNr)
2273 ok = _MsgYesNo()
2274 if ok = 1 then do
2275 if RID.SelGNr <> "" then do
2276 say samba.!netexe' rpc group delete "'NTGroupname.SelGNr'" 'UserCred
2277 address cmd samba.!netexe' rpc group delete "'NTGroupname.SelGNr'" 'UserCred' 2>'samba.!error' 1>'samba.!msg
2278 if RC <> 0 then do
2279 call _SambaShowError
2280 return
2281 end
2282 else call _SambaShowMsg
2283 end
2284 do I = 1 to Username.0
2285 if GID.I = GGID.SelGNr then do
2286 GID.I = UID.I
2287 ok = VRMethod("CN_users","SetFieldData", RH.I, GIDFH, GID.I)
2288 end
2289 end
2290 ok = SysStemDelete("groupname.", SelGNr)
2291 ok = SysStemDelete("gpasswd.", SelGNr)
2292 ok = SysStemDelete("ggid.", SelGNr)
2293 ok = SysStemDelete("gusers.", SelGNr)
2294 ok = SysStemDelete("NTGroupname.",SelGNr)
2295 ok = SysStemDelete("RID.", SelGNr)
2296 ok = SysStemDelete("Gstatus.", SelGNr)
2297 ok = VRMethod("CN_Groups", "RemoveRecord", SelGRH.1)
2298 call PB_Save_Click
2299 call PB_Refresh_Click
2300 end
2301return
2302
2303/*:VRX Contextmenu_GroupDetailView_Click
2304*/
2305Contextmenu_GroupDetailView_Click:
2306 ok = VRSet("CN_Groups", "View", "Detail")
2307return
2308
2309/*:VRX Contextmenu_GroupMap_Click
2310*/
2311Contextmenu_GroupMap_Click:
2312 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2313 if SelGRH.0 = 0 then return
2314 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2315say 'Selected Group Nr = ' SelGNr
2316 if RID.SelGnr <> "" then do
2317 Msg.Type = "E"
2318 Msg.Title = NLVGetMessage(91)
2319 Msg.Text = NLVGetMessage(114,Groupname.SelGNr)
2320 call _showMsg
2321 return
2322 end
2323 window = VRLoadSecondary( "MapGroup", "W" )
2324return
2325
2326/*:VRX Contextmenu_GroupMembers_Click
2327*/
2328Contextmenu_GroupMembers_Click:
2329 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2330 if SelGRH.0 = 0 then return
2331 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2332say 'Selected Group Nr = ' SelGNr
2333 CurNTGroupName = NTGroupname.SelGNr
2334 window = VRLoadSecondary( "Group_Members", "W" )
2335return
2336
2337/*:VRX Contextmenu_GroupRebuildScript_Click
2338*/
2339Contextmenu_GroupRebuildScript_Click:
2340 RebuildScript = VRFileDialog( VRWindow(), NLVGetMessage( 99 ), "Save", samba.!bin"\RebuildGroups.CMD", , , )
2341 if RebuildScript = "" then return
2342 ok = SysFileDelete(RebuildScript)
2343 call lineout RebuildScript,'@echo off'
2344 call lineout RebuildScript, 'rem Created by SmbUsers 'VRGet("Main","Hinttext")
2345 do I = 1 to groupname.0
2346 if RID.I <> "" then do
2347 select
2348 when left(translate(NTGroupType.I),4) = "WELL" then Gtype = 'builtin'
2349 when left(translate(NTGroupType.I),4) = "LOCA" then Gtype = 'local'
2350 otherwise Gtype = 'domain'
2351 end
2352 call lineout RebuildScript, 'net groupmap add rid='RID.I' ntgroup="'NTGroupName.I'" unixgroup="'Groupname.I'" type='GType' comment="'NTComment.I'"'
2353 end
2354 end
2355 call lineout RebuildScript, 'echo Done.'
2356 Msg.Title = NLVGetMessage( 98 )
2357 Msg.Type = "I"
2358 Msg.Text = NLVGetMessage( 108, RebuildScript )
2359 call _ShowMsg
2360return
2361
2362/*:VRX Contextmenu_GroupSymbolView_Click
2363*/
2364Contextmenu_GroupSymbolView_Click:
2365 ok = VRSet("CN_Groups", "View", "Icon")
2366return
2367
2368/*:VRX Contextmenu_GroupUnmap_Click
2369*/
2370Contextmenu_GroupUnmap_Click:
2371 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2372 if SelGRH.0 = 0 then return
2373 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2374say 'Selected Group Nr = ' SelGNr
2375 if RID.SelGnr = "" then do
2376 Msg.Type = "E"
2377 Msg.Title = NLVGetMessage( 95 )
2378 Msg.Text = NLVGetMessage(96, Groupname.SelGNr )
2379 call _showMsg
2380 return
2381 end
2382 Msg.Type = "E"
2383 Msg.Title = NLVGetMessage( 95 )
2384 Msg.Text = NLVGetMessage( 97, NTGroupname.SelGNr, GroupName.SelGNr )
2385 ok = _MsgYesNo()
2386 if ok = 1 then do
2387 blGusers = translate(Gusers.SelGnr,' ',',')
2388 do I = 1 to words(blGusers)
2389 address cmd samba.!netexe' rpc group delmem "'NTGroupname.SelGNr'" 'word(BlGusers,I)' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2390 if RC <> 0 then call _SambaShowError
2391 else call _SambaShowMsg
2392 say samba.!netexe' RC = 'RC
2393 end
2394 say samba.!netexe' groupmap delete ntgroup="'NTGroupname.SelGNr'" 'debuglevel
2395 address cmd samba.!netexe' groupmap delete ntgroup="'NTGroupname.SelGNr'" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2396 if RC <> 0 then call _SambaShowError
2397 else call _SambaShowMsg
2398 call PB_Refresh_Click
2399 end
2400return
2401
2402/*:VRX Contextmenu_GroupWellKnown_Click
2403*/
2404Contextmenu_GroupWellKnown_Click:
2405 if Groupname.0 <> 0 then do
2406 Msg.Title = NLVGetMessage( 92 )
2407 Msg.Text = NLVGetMessage( 93 )
2408 Msg.Type = "W"
2409 call _ShowMsg
2410 return
2411 end
2412 call _kLIBCGroupADD "admins", 512
2413 call _kLIBCGroupADD "users", 513
2414 call _kLIBCGroupADD "guests", 514
2415 call _kLIBCGroupADD "machines", 515
2416 call _kLIBCGroupADD "dc", 516
2417 call _kLIBCGroupADD "certadmin", 517
2418 call _kLIBCGroupADD "schemeadmin", 518
2419 call _kLIBCGroupADD "entadmin", 519
2420 call _kLIBCGroupADD "poladmin", 520
2421 call PB_Save_Click
2422
2423 address cmd samba.!netexe' groupmap add rid=512 ntgroup="Domain Admins" unixgroup="admins" type=domain comment="Domain Administrators" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2424 if RC <> 0 then call _SambaShowError
2425
2426 address cmd samba.!netexe' groupmap add rid=513 ntgroup="Domain Users" unixgroup="users" type=domain comment="Domain Users" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2427 if RC <> 0 then call _SambaShowError
2428
2429 address cmd samba.!netexe' groupmap add rid=514 ntgroup="Domain Guests" unixgroup="guests" type=domain comment="Domain Guest Accounts" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2430 if RC <> 0 then call _SambaShowError
2431
2432 address cmd samba.!netexe' groupmap add rid=515 ntgroup="Domain Computers" unixgroup="machines" type=domain comment="Domain Computers" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2433 if RC <> 0 then call _SambaShowError
2434
2435 address cmd samba.!netexe' groupmap add rid=516 ntgroup="Domain Controllers" unixgroup="dc" type=domain comment="Domain Controllers" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2436 if RC <> 0 then call _SambaShowError
2437
2438 address cmd samba.!netexe' groupmap add rid=517 ntgroup="Domain Certificate Admins" unixgroup="certadmin" type=domain comment="Domain Certificate Administrators" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2439 if RC <> 0 then call _SambaShowError
2440
2441 address cmd samba.!netexe' groupmap add rid=518 ntgroup="Domain Scheme Admins" unixgroup="schemeadmin" type=domain comment="Domain Scheme Administrators" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2442 if RC <> 0 then call _SambaShowError
2443
2444 address cmd samba.!netexe' groupmap add rid=519 ntgroup="Domain Enterprise Admins" unixgroup="entadmin" type=domain comment="Domain Enterprise Administrators" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2445 if RC <> 0 then call _SambaShowError
2446
2447 address cmd samba.!netexe' groupmap add rid=520 ntgroup="Domain Policy Admins" unixgroup="poladmin" type=domain comment="Domain Policy Administrators" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2448 if RC <> 0 then call _SambaShowError
2449
2450 Msg.Title = NLVGetMessage( 92 )
2451 Msg.Type = "I"
2452 Msg.Text = NLVGetMessage( 94 )
2453 call _ShowMsg
2454 call PB_Refresh_Click
2455return
2456
2457/*:VRX Contextmenu_UserAdd_Click
2458*/
2459Contextmenu_UserAdd_Click:
2460 IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() started'
2461 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2462 if SelRH.0 = 0 then do
2463 IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() done, aborted'
2464 return
2465 end
2466 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2467/* IF options.!debug == 1 THEN say ' Flags.SelNr = "'flags.SelNr'"' */
2468 if flags.SelNr = "" then IsUnixUser = 1
2469 else IsUnixUser = 0
2470 IF options.!debug == 1 THEN say ' Selected User Nr = 'SelNr
2471 IF options.!debug == 1 THEN say ' Is kLIBC User only? 'IsUnixUser
2472 window = VRLoadSecondary( "AddUser", "W" )
2473 IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() done'
2474return
2475
2476/*:VRX Contextmenu_UserDel_Click
2477*/
2478Contextmenu_UserDel_Click:
2479 IF options.!debug == 1 THEN say 'Contextmenu_UserDel_Click() started'
2480 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2481 if SelRH.0 = 0 then return
2482 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2483 IF options.!debug == 1 THEN say ' Selected User Nr = 'SelNr
2484 Msg.Title = NLVGetMessage(50)
2485 Msg.Text = NLVGetMessage(51, '"'Username.SelNr'" (UID: 'UID.SelNr')')
2486 ok = _MsgYesNo()
2487 if ok = 1 then do
2488 if flags.SelNr <> "" then do
2489 say ' 'samba.!netexe' rpc user delete "'Username.SelNr'" 'UserCred' 'Debuglevel' 2>'samba.!error' 1>'samba.!msg
2490 address cmd samba.!netexe' rpc user delete "'Username.SelNr'" 'UserCred' 'Debuglevel' 2>'samba.!error' 1>'samba.!msg
2491 if rc <> 0 then call _SambaShowError; else call _SambaShowMsg
2492 if swatauth then do
2493 say ' 'samba.!htpasswdexe' -D "'swatusers'" 'Username.SelNr
2494 address cmd samba.!htpasswdexe' -D "'swatusers'" 'Username.SelNr' 2>'samba.!error' 1>'samba.!msg
2495 if rc <> 0 then call _SambaShowError
2496 else call _SambaShowMsg
2497 end
2498 end
2499 else do /* kLIBC user only */
2500 ExUserName = Username.SelNr
2501 ExUID = UID.SelNr
2502 ExGID = GID.SelNr
2503 ok = SysStemDelete("username.",SelNr)
2504 ok = SysStemDelete("password.",SelNr)
2505 ok = SysStemDelete("uid.",SelNr)
2506 ok = SysStemDelete("gid.",SelNr)
2507 ok = SysStemDelete("loginclass.",SelNr)
2508 ok = SysStemDelete("pwchange.",SelNr)
2509 ok = SysStemDelete("deact.",SelNr)
2510 ok = SysStemDelete("gecos.",SelNr)
2511 ok = SysStemDelete("home.",SelNr)
2512 ok = SysStemDelete("shell.",SelNr)
2513 ok = SysStemDelete("status.",SelNr)
2514 ok = SysStemDelete("lmhash.",SelNr)
2515 ok = SysStemDelete("nthash.",SelNr)
2516 ok = SysStemDelete("flags.",SelNr)
2517 ok = SysStemDelete("lct.",SelNr)
2518 do I = 1 to gusers.0
2519 blGUsers = translate(Gusers.I,' ',',')
2520 UPos = wordpos(translate(ExUserName),translate(blGusers))
2521 if Upos > 0 then do
2522 blGUsers = delword(BlGusers,UPos,1)
2523 Gusers.I = translate(blGusers,',',' ')
2524 end
2525 end
2526 call PB_Save_Click
2527 Msg.Title = NLVGetMessage(50)
2528 Msg.Text = NLVGetMessage(53, '"'ExUsername'"' )
2529 Msg.Type = 'I'
2530 call _ShowMsg
2531 end
2532 call PB_Refresh_Click
2533 end
2534 IF options.!debug == 1 THEN say 'Contextmenu_UserDel_Click() done'
2535return
2536
2537/*:VRX Contextmenu_UserDetailView_Click
2538*/
2539Contextmenu_UserDetailView_Click:
2540 ok = VRSet("CN_users", "View", "Detail")
2541return
2542
2543/*:VRX Contextmenu_UserJoinGroup_Click
2544*/
2545Contextmenu_UserJoinGroup_Click:
2546 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2547 if SelRH.0 = 0 then return
2548 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2549 say 'Selected User Nr = ' SelNr
2550 window = VRLoadSecondary( "Join_Group", "W" )
2551return
2552
2553/*:VRX Contextmenu_UserLeaveGroup_Click
2554*/
2555Contextmenu_UserLeaveGroup_Click:
2556 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2557 if SelRH.0 = 0 then return
2558 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2559 say 'Selected User Nr = ' SelNr
2560 window = VRLoadSecondary( "Leave_Group", "W" )
2561return
2562
2563/*:VRX Contextmenu_UserProperties_Click
2564*/
2565Contextmenu_UserProperties_Click:
2566 window = VRLoadSecondary( "UserProperties", "W" )
2567return
2568
2569/*:VRX Contextmenu_UserSymbolView_Click
2570*/
2571Contextmenu_UserSymbolView_Click:
2572 ok = VRSet("CN_users", "View", "Icon")
2573return
2574
2575/*:VRX DDCB_GID_Change
2576*/
2577DDCB_GID_Change:
2578 ok = VRSet("DT_PrimaryGroupName","Caption","UID")
2579 if VRGet("DDCB_GID","Value") = NextUID then return
2580 do x = 1 to groupname.0
2581 if VRGet("DDCB_GID","Value") = GGID.x then do
2582 ok = VRSet("DT_PrimaryGroupName","Caption",groupname.x' ('NTGroupName.x')')
2583 leave
2584 end
2585 end
2586return
2587
2588/*:VRX DDCB_Policy_Change
2589*/
2590DDCB_Policy_Change:
2591 say samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" 'DebugLevel' 1>'samba.!msg' 2>'samba.!error
2592 address cmd samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" 'DebugLevel' 1>'samba.!msg
2593 PolDesc = linein(samba.!msg)
2594 PolValue = linein(samba.!msg)
2595 ok = stream(Samba.!msg,'c','close')
2596
2597 parse var PolDesc . ':' PolDesc
2598 parse var PolValue . ':' PolValue
2599say strip(PolValue)
2600say strip(PolDesc)
2601 ok = VRset("EF_PolValue","Value",strip(PolValue))
2602 ok = VRSet("GB_Policy","HintText",strip(PolDesc))
2603return
2604
2605/*:VRX EF_Comment_Change
2606*/
2607EF_Comment_Change:
2608 if pos(':',VRGet("EF_GroupName","Value")) > 0 then ok = VRset("EF_Groupname","Value",translate(VRGet("EF_GroupName","Value"),'-',':'))
2609return
2610
2611/*:VRX EF_Description_Change
2612*/
2613EF_Description_Change:
2614 if VRGet("EF_Description","value") <> "" then do
2615 SecondStage = 1
2616 end
2617 else SecondStage = (SecondStage | 0)
2618return
2619
2620/*:VRX EF_GGID_Change
2621*/
2622EF_GGID_Change:
2623 if VRGet("EF_GGID","Value") <> "" then do
2624 if datatype(VRGet("EF_GGID","Value")) <> "NUM" then ok = VRSet("EF_GGID","Value","")
2625 end
2626return
2627
2628/*:VRX EF_Groupname_Change
2629*/
2630EF_Groupname_Change:
2631 if pos(':',VRGet("EF_GroupName","Value")) > 0 then ok = VRset("EF_Groupname","Value",translate(VRGet("EF_GroupName","Value"),'-',':'))
2632return
2633
2634/*:VRX EF_Home_Change
2635*/
2636EF_Home_Change:
2637 if pos('NONEXISTENT', translate(VRGet("EF_Home", "Value"))) > 0 then do
2638 ok = VRset("PB_CreateHome","Enabled",0)
2639 return
2640 end
2641
2642 if \VRFileExists( VRGet("EF_Home", "Value") ) then do
2643 ok = VRSet("EF_Home","ForeColor", "Red")
2644 ok = VRset("PB_CreateHome","Enabled",\VRGet("CB_NoHome","set"))
2645 end
2646 else do
2647 ok = VRSet("EF_Home","ForeColor", "<default>")
2648 ok = VRset("PB_CreateHome","Enabled",0)
2649 end
2650return
2651
2652/*:VRX EF_LoginPassword_KeyPress
2653*/
2654EF_LoginPassword_KeyPress:
2655 obj = VRInfo( "Object" )
2656 keystr = VRGet( obj, "KeyString" )
2657/* say keystr */
2658 select
2659 when keystr = "{Enter}" then call PB_LOGIN_OK_Click
2660 when keystr = "{Newline}" then call PB_LOGIN_OK_Click
2661 when keystr = "{Esc}" then call PB_LOGIN_CANCEL_Click
2662 otherwise nop
2663 end
2664return
2665
2666/*:VRX EF_LoginUser_KeyPress
2667*/
2668EF_LoginUser_KeyPress:
2669 obj = VRInfo( "Object" )
2670 keystr = VRGet( obj, "KeyString" )
2671/* say keystr */
2672 select
2673 when keystr = "{Enter}" then ok = VRMethod( "EF_LoginPassword", "SetFocus" )
2674 when keystr = "{Newline}" then ok = VRMethod( "EF_LoginPassword", "SetFocus" )
2675 when keystr = "{Esc}" then call PB_LOGIN_CANCEL_Click
2676 otherwise nop
2677 end
2678return
2679
2680/*:VRX EF_upPassword_Change
2681*/
2682EF_upPassword_Change:
2683 ok = VRSet("CB_upSWAT_Allowed","Enabled",1)
2684return
2685
2686/*:VRX EF_Username_Change
2687*/
2688EF_Username_Change:
2689 if pos(':',VRGet("EF_Username","Value")) > 0 then ok = VRset("EF_Username","Value",translate(VRGet("EF_Username","Value"),'-',':'))
2690 ok = VRSet("EF_Home","Value", Samba.!homes'\'VRGet("EF_Username","Value"))
2691 call CB_MachineAccount_Click
2692 if VRGet("EF_Username","Value") = "" then do
2693 if IsUnixUser then do
2694 IsUnixuser = 0
2695 drop UnixUserNr
2696 ok = VRSet( "DT_UID", "BackColor", "<default>")
2697 ok = VRSet( "DT_UID", "ForeColor", "<default>")
2698 NextUID = _GetNextUID(VRGet("EF_Username","value"))
2699 IsUnixUser = 0
2700 ok = VRSet("DT_UID","Caption", "UID: "NextUID)
2701 ok = VRSet("DDCB_GID","Value", NextUID)
2702 ok = VRMethod( "DDCB_GID", "Reset")
2703 ok = VRMethod( "DDCB_GID", "AddString", NextUID)
2704 ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.")
2705 ok = VRSet("EF_GECOS","Value","")
2706 ok = VRSet("EF_Home","Value","")
2707 end
2708 end
2709 else do
2710 NextUID = _GetNextUID(VRGet("EF_Username","value"))
2711 ok = VRSet("DT_UID","Caption", "UID: "NextUID)
2712 if NextUID > 65000 then do
2713 ok = VRset("EF_Description","Value",NLVGetMessage(116))
2714 ok = VRset("CB_NoPassword","set", 1)
2715 call CB_NoPassword_Click
2716 ok = VRset("DDCB_GID","value",NextUID)
2717 ok = VRMethod("DDCB_GID","addString", NextUID)
2718 end
2719 else ok = VRset("DDCB_GID","value","513")
2720 end
2721return
2722
2723/*:VRX EF_Username_LostFocus
2724*/
2725EF_Username_LostFocus:
2726 do I = 1 to Username.0
2727 if translate(Username.I) = translate(VRGet("EF_username","value")) then do
2728 if flags.I = "" then do
2729 IsUnixuser = 1
2730 UnixUserNr = I
2731 ok = VRSet( "DT_UID", "BackColor", "DarkGreen")
2732 ok = VRSet( "DT_UID", "ForeColor", "White")
2733 ok = VRSet( "DT_UID", "Caption", "UID: "UID.I)
2734 ok = VRSet( "EF_GECOS","Value", GECOS.I)
2735 ok = VRSet( "DDCB_GID","Value", GID.I)
2736 ok = VRMethod( "DDCB_GID", "Reset")
2737 ok = VRMethod( "DDCB_GID", "AddString", UID.I)
2738 ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.")
2739 ok = VRSet( "EF_Home","Value", _PathStrOS2(Home.I))
2740 end
2741 else do
2742 Msg.Type = "E"
2743 Msg.Text = NLVGetMessage( 105)
2744 call _ShowMsg
2745 ok = VRSet("EF_username","value","")
2746 ok = VRMethod("EF_username","SetFocus")
2747 end
2748 leave
2749 end
2750 end
2751return
2752
2753/*:VRX Fini
2754*/
2755Fini:
2756 window = VRWindow()
2757 call VRSet window, "Visible", 0
2758 drop window
2759return 0
2760
2761/*:VRX GetBootDrive
2762*/
2763GetBootDrive:
2764/* Use SysBootDrive if possible */
2765If Rxfuncadd('SysBootDrive', 'RexxUtil', 'SysBootDrive') Then
2766 Return Left(Value('RUNWORKPLACE',,'OS2ENVIRONMENT'),2)
2767Else
2768 Return SysBootDrive()
2769
2770
2771/*:VRX Group_Members_Close
2772*/
2773Group_Members_Close:
2774 call Group_Members_Fini
2775return
2776
2777/*:VRX Group_Members_Create
2778*/
2779Group_Members_Create:
2780 call Group_Members_Init
2781 ok = VRSet("Group_Members","Caption", NLVGetMessage(89)||' "'CurNTGroupName'"')
2782 CALL NLVSetText 'PB_GroupMembersOK', 'Caption', 2
2783
2784 ok = VRMethod("LB_GroupMembers","Reset")
2785 ok = VRSet("Main", 'Pointer', 'Wait' )
2786 say samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2787 address cmd samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2788 if RC <> 0 then call _SambaShowError
2789 else do
2790 do while lines(samba.!msg) <> 0
2791 groupmember = linein(samba.!msg)
2792 say groupmember
2793 ok = VRMethod("LB_GroupMembers","AddString", groupmember)
2794 end
2795 ok = stream(Samba.!msg,"c","close")
2796 end
2797 ok = VRSet("Main", 'Pointer', '<default>' )
2798return
2799
2800/*:VRX Group_Members_Fini
2801*/
2802Group_Members_Fini:
2803 window = VRInfo( "Window" )
2804 call VRDestroy window
2805 drop window
2806return
2807/*:VRX Group_Members_Init
2808*/
2809Group_Members_Init:
2810 window = VRInfo( "Object" )
2811 if( \VRIsChildOf( window, "Notebook" ) ) then do
2812 call VRMethod window, "CenterWindow"
2813 call VRSet window, "Visible", 1
2814 call VRMethod window, "Activate"
2815 end
2816 drop window
2817return
2818
2819/*:VRX Halt
2820*/
2821Halt:
2822 signal _VREHalt
2823return
2824
2825/*:VRX Init
2826*/
2827Init:
2828window = VRWindow()
2829call VRMethod window, "CenterWindow"
2830call VRSet window, "Visible", 0
2831call VRMethod window, "Activate"
2832drop window
2833return
2834
2835/*:VRX IPB_AccountFlags_Click
2836*/
2837IPB_AccountFlags_Click:
2838 ok = VRSet("IPB_AccountFlags","PicturePath", "#16;#16")
2839 ok = VRSet("IPB_Profile","PicturePath", "#27;#27")
2840 ok = VRSet("IPB_Memberships","PicturePath", "#28;#28")
2841
2842 ok = VRSet("GB_Flags","Left", 140)
2843 ok = VRSet("GB_Flags","Top", 140)
2844 ok = VRSet("GB_Flags","Width", VRGet("GB_upOuter","Width") - 280)
2845 ok = VRSet("GB_Flags","Height",VRGet("GB_upOuter","Height") - 280)
2846 ok = VRSet("GB_GroupMemberShips","Visible", 0)
2847 ok = VRset("GB_Profile", "Visible", 0)
2848 ok = VRSet("GB_Flags","Visible", 1)
2849return
2850
2851/*:VRX IPB_GroupAdd_Click
2852*/
2853IPB_GroupAdd_Click:
2854 call Contextmenu_GroupAdd_Click
2855return
2856
2857/*:VRX IPB_GroupDel_Click
2858*/
2859IPB_GroupDel_Click:
2860 call Contextmenu_GroupDel_Click
2861return
2862
2863/*:VRX IPB_GroupMap_Click
2864*/
2865IPB_GroupMap_Click:
2866 call Contextmenu_GroupMap_Click
2867return
2868
2869/*:VRX IPB_GroupScript_Click
2870*/
2871IPB_GroupScript_Click:
2872 call Contextmenu_GroupRebuildScript_Click
2873return
2874
2875/*:VRX IPB_GroupUnMap_Click
2876*/
2877IPB_GroupUnMap_Click:
2878 call Contextmenu_GroupUnMap_Click
2879return
2880
2881/*:VRX IPB_GroupWellknown_Click
2882*/
2883IPB_GroupWellknown_Click:
2884 call Contextmenu_GroupWellKnown_Click
2885return
2886
2887/*:VRX IPB_Memberships_Click
2888*/
2889IPB_Memberships_Click:
2890 ok = VRSet("IPB_AccountFlags","PicturePath", "#26;#26")
2891 ok = VRSet("IPB_Profile","PicturePath", "#27;#27")
2892 ok = VRSet("IPB_Memberships","PicturePath", "#18;#18")
2893
2894 ok = VRSet("GB_GroupMemberShips","Left", 140)
2895 ok = VRSet("GB_GroupMemberShips","Top", 140)
2896 ok = VRSet("GB_GroupMemberShips","Width", VRGet("GB_upOuter","Width") - 280)
2897 ok = VRSet("GB_GroupMemberShips","Height",VRGet("GB_upOuter","Height") - 280)
2898 ok = VRSet("GB_GroupMemberShips","Visible", 1)
2899 ok = VRset("GB_Flags", "Visible", 0)
2900 ok = VRset("GB_Profile", "Visible", 0)
2901 ok = VRMethod("LB_upGroups","Reset")
2902 ok = VRSet("Main", 'Pointer', 'Wait' )
2903 address cmd samba.!netexe' rpc user info 'Username.CurUserNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2904 if RC <> 0 then call _SambaShowError
2905 else do
2906 do while lines(samba.!msg) <> 0
2907 ok = VRMethod("LB_upGroups","AddString", linein(samba.!msg))
2908 end
2909 ok = stream(Samba.!msg,"c","close")
2910 end
2911 ok = VRSet("Main", 'Pointer', '<default>' )
2912return
2913
2914/*:VRX IPB_Paper_Click
2915*/
2916IPB_Paper_Click:
2917 if VRInfo("Left") > VRInfo("Top") then call Activate min(CurrentPageNr+1,Pages)
2918 if VRInfo("Left") <= VRInfo("Top") then call Activate max(CurrentPageNr-1,1)
2919return
2920
2921/*:VRX IPB_Profile_Click
2922*/
2923IPB_Profile_Click:
2924 ok = VRSet("IPB_AccountFlags","PicturePath", "#26;#26")
2925 ok = VRSet("IPB_Profile","PicturePath", "#17;#17")
2926 ok = VRSet("IPB_Memberships","PicturePath", "#28;#28")
2927
2928 ok = VRSet("GB_Profile","Left", 140)
2929 ok = VRSet("GB_Profile","Top", 140)
2930 ok = VRSet("GB_Profile","Width", VRGet("GB_upOuter","Width") - 280)
2931 ok = VRSet("GB_Profile","Height",VRGet("GB_upOuter","Height") - 280)
2932 ok = VRSet("CN_UserProperties","Width",VRGet("GB_Profile","Width")-240)
2933 ok = VRset("GB_Flags", "Visible", 0)
2934 ok = VRSet("GB_GroupMemberShips","Visible", 0)
2935 ok = VRSet("GB_Profile","Visible", 1)
2936return
2937
2938/*:VRX IPB_UserAdd_Click
2939*/
2940IPB_UserAdd_Click:
2941 call Contextmenu_UserAdd_Click
2942return
2943
2944/*:VRX IPB_UserDel_Click
2945*/
2946IPB_UserDel_Click:
2947 call Contextmenu_UserDel_Click
2948return
2949
2950/*:VRX IPB_UserJoinGroup_Click
2951*/
2952IPB_UserJoinGroup_Click:
2953 call Contextmenu_UserJoinGroup_Click
2954return
2955
2956/*:VRX IPB_UserLeaveGroup_Click
2957*/
2958IPB_UserLeaveGroup_Click:
2959 call Contextmenu_UserLeaveGroup_Click
2960return
2961
2962/*:VRX Join_Group_Close
2963*/
2964Join_Group_Close:
2965 call Join_Group_Fini
2966return
2967
2968/*:VRX Join_Group_Create
2969*/
2970Join_Group_Create:
2971 call Join_Group_Init
2972 CALL NLVSetText 'Join_Group', 'Caption', 80
2973 CALL NLVSetText 'DT_JoinGroup', 'Caption', 81
2974 CALL NLVSetText 'PB_JoinOK', 'Caption', 2
2975 CALL NLVSetText 'PB_JoinCancel', 'Caption', 3
2976
2977 call VRSet "LB_Groups", "Painting", 0
2978 ok = VRMethod("LB_Groups","AddStringList", "NTGroupName.")
2979 address cmd samba.!netexe' rpc user info 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2980 if RC <> 0 then call _SambaShowError
2981 else do
2982 do while lines(samba.!msg) <> 0
2983 AlreadyMember = linein(samba.!msg)
2984 ok = VRMethod( "LB_Groups", "DeleteString", AlreadyMember )
2985 if settings.!FixErrors then do
2986 do I = 1 to NTGroupName.0
2987 if AlreadyMember = NTGroupName.I then do
2988 if pos(Username.SelNr,GUsers.I) = 0 then do
2989 Gusers.I = Username.SelNr','Gusers.I
2990 ok = VRMethod("CN_Groups", "SetFieldData", GRH.I, GUsersFH, Gusers.I)
2991 call _GroupWrite
2992 end
2993 end
2994 end
2995 end
2996 end
2997 ok = stream(Samba.!msg,"c","close")
2998 end
2999 call VRSet "LB_Groups", "Painting", 1
3000return
3001
3002/*:VRX Join_Group_Fini
3003*/
3004Join_Group_Fini:
3005 window = VRInfo( "Window" )
3006 call VRDestroy window
3007 drop window
3008return
3009/*:VRX Join_Group_Init
3010*/
3011Join_Group_Init:
3012 window = VRInfo( "Object" )
3013 if( \VRIsChildOf( window, "Notebook" ) ) then do
3014 call VRMethod window, "CenterWindow"
3015 call VRSet window, "Visible", 1
3016 call VRMethod window, "Activate"
3017 end
3018 drop window
3019return
3020
3021/*:VRX Leave_Group_Close
3022*/
3023Leave_Group_Close:
3024 call Leave_Group_Fini
3025return
3026
3027/*:VRX Leave_Group_Create
3028*/
3029Leave_Group_Create:
3030 call Leave_Group_Init
3031 CALL NLVSetText 'Leave_Group', 'Caption', 85
3032 CALL NLVSetText 'DT_LeaveGroup', 'Caption', 86
3033 CALL NLVSetText 'PB_LeaveOK', 'Caption', 2
3034 CALL NLVSetText 'PB_LeaveCancel', 'Caption', 3
3035 address cmd samba.!netexe' rpc user info 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3036 if RC <> 0 then call _SambaShowError
3037 else do
3038 call VRSet "LB_LeaveGroups", "Painting", 0
3039 do while lines(samba.!msg) <> 0
3040 ok = VRMethod("LB_LeaveGroups","AddString", linein(samba.!msg))
3041 end
3042 ok = stream(Samba.!msg,"c","close")
3043 call VRSet "LB_LeaveGroups", "Painting", 1
3044 end
3045return
3046
3047/*:VRX Leave_Group_Fini
3048*/
3049Leave_Group_Fini:
3050 window = VRInfo( "Window" )
3051 call VRDestroy window
3052 drop window
3053return
3054/*:VRX Leave_Group_Init
3055*/
3056Leave_Group_Init:
3057 window = VRInfo( "Object" )
3058 if( \VRIsChildOf( window, "Notebook" ) ) then do
3059 call VRMethod window, "CenterWindow"
3060 call VRSet window, "Visible", 1
3061 call VRMethod window, "Activate"
3062 end
3063 drop window
3064return
3065
3066/*:VRX Main_Close
3067*/
3068Main_Close:
3069 call Quit
3070return
3071
3072/*:VRX Main_Create
3073*/
3074Main_Create:
3075 options.!debug = 0
3076 /* Default title */
3077 Msg.Title = VRGet("Main", "Caption")
3078
3079 call _LoadOtherFuncs
3080 call _IniRead
3081 call _NLVSetup
3082
3083 /* Nationalized title */
3084 Msg.Title = VRGet("Main", "Caption")
3085 call _InitTempdir
3086 call _ParseCommandLine
3087
3088 StartSamba = \_SambaRunning()
3089
3090 call _SambaInit
3091 if ErrorState then call _OnErrorDisable
3092 if StartSamba then do
3093 address cmd samba.!smbcmd' start'
3094 end
3095 if \_SambaRunning() then do
3096 Msg.Text = NLVGetMessage(107)
3097 Msg.Type = "E"
3098 call _ShowMsg
3099 call Quit
3100 return
3101 end
3102 else if StartSamba then do
3103 Msg.Text = NLVGetMessage(109)
3104 Msg.Type = "I"
3105 call _ShowMsg
3106 end
3107
3108 call _SambaGetProperties
3109
3110 call _FindHtpasswd
3111
3112 call _ContainersInit
3113
3114 call _MasterPasswdRead
3115 call _Login
3116
3117 call _SmbpasswdRead
3118 call _SmbUserMapRead
3119 call _GroupRead
3120 call _SmbGroupsRead
3121
3122 call _GUIInit
3123
3124 call _ContainerPopulate
3125 call _ContGroupsPopulate
3126 call _PoliciesPopulate
3127
3128 ok = VRMethod("PB_Exit","SetFocus")
3129 call TAB_1_Click
3130 call Main_Resize
3131return
3132/*:VRX Main_Resize
3133*/
3134Main_Resize:
3135 IF options.!debug == 1 THEN say 'Main_Resize() started.'
3136 MainWin = "Main"
3137 ok = VRSet(MainWin,"Painting", 0)
3138/* ok = VRset(MainWin,"Visible", 0) */
3139 ok = VRSet(MainWin,"Width",max(VRget(MainWin,"Width"),Pages*TabWidth+300))
3140 ok = VRset("GB_Main","width",VRget(MainWin,"Width")-150)
3141 ok = VRset("GB_Main","Height",VRget(MainWin,"Height")-1175-240)
3142 ok = VRset("GB_Main2","width",VRget("GB_Main","Width")-260)
3143 ok = VRset("GB_Main2","Height",VRget("GB_Main","Height")-275)
3144 ok = VRset("GB_VerticalLine","Left",VRget("GB_Main2","Width")-60)
3145 ok = VRset("GB_VerticalLine","Height",VRget("GB_Main2","Height")-410)
3146 ok = VRset("IPB_Paper","Left",VRget("GB_Main2","width")-420)
3147 ok = VRset("GB_HorLineTop","Width",VRget("GB_Main2","width")-440)
3148 ok = VRset("GB_HorLineTop","Width",VRget("GB_Main2","width")-440)
3149 ok = VRset("GB_LineSubtitle","Width",VRget("GB_Main2","width")-480)
3150 do I = 1 to Pages
3151 /* say 'Page_'I'='max(PageHeight,VRget("GB_Main2","Height")-600) */
3152 ok = VRSet("Page_"I,"Height", max(PageHeight,VRget("GB_Main2","Height")-600))
3153 ok = VRSet("Page_"I,"Width", max(PageWidth,VRget("GB_Main2","Width")-450))
3154 end
3155
3156 /* Main window buttons */
3157 ok = VRSEt("PB_RPC", "top",VRGet("GB_Main","Height")+305)
3158 ok = VRSEt("PB_Help", "top",VRGet("GB_Main","Height")+305)
3159 ok = VRSEt("PB_Save", "top",VRGet("GB_Main","Height")+305)
3160 ok = VRSEt("PB_Refresh","top",VRGet("GB_Main","Height")+305)
3161 ok = VRSEt("PB_Exit", "top",VRGet("GB_Main","Height")+305)
3162 ok = VRSEt("PB_About", "top",VRGet("GB_Main","Height")+305)
3163
3164 /* Users page */
3165 ok = VRset("CN_Users","Top", 120)
3166 ok = VRset("CN_Users","Left", 20)
3167 ok = VRset("CN_Users","Width", VRGet("Page_1","Width")-600)
3168 ok = VRset("CN_Users","Height", VRGet("Page_1","Height")-360)
3169 ok = VRset("CB_SmbOnly","Left", 20)
3170 ok = VRset("CB_SmbOnly","Top", VRGet("CN_Users","Height")+120 )
3171 ok = VRSet("IPB_UserAdd", "Top", 120 )
3172 ok = VRSet("IPB_UserAdd", "Left", VRGet("CN_Users","Width") + 80 )
3173 ok = VRSet("IPB_UserDel", "Top", 720 )
3174 ok = VRSet("IPB_UserDel", "Left", VRGet("CN_Users","Width") + 80 )
3175 ok = VRSet("IPB_UserJoinGroup", "Top", 1320 )
3176 ok = VRSet("IPB_UserJoinGroup", "Left", VRGet("CN_Users","Width") + 80 )
3177 ok = VRSet("IPB_UserLeaveGroup", "Top", 1920 )
3178 ok = VRSet("IPB_UserLeaveGroup", "Left", VRGet("CN_Users","Width") + 80 )
3179
3180
3181 /* Groups page */
3182 ok = VRset("CN_Groups","Top", 120)
3183 ok = VRset("CN_Groups","Left", 20)
3184 ok = VRset("CN_Groups","Width", VRGet("Page_2","Width")-600)
3185 ok = VRset("CN_Groups","Height", VRGet("Page_2","Height")-360)
3186 ok = VRSet("IPB_GroupAdd", "Top", 120 )
3187 ok = VRSet("IPB_GroupAdd", "Left", VRGet("CN_Users","Width") + 80 )
3188 ok = VRSet("IPB_GroupMap", "Top", 720 )
3189 ok = VRSet("IPB_GroupMap", "Left", VRGet("CN_Users","Width") + 80 )
3190 ok = VRSet("IPB_GroupDel", "Top", 1320 )
3191 ok = VRSet("IPB_GroupDel", "Left", VRGet("CN_Users","Width") + 80 )
3192 ok = VRSet("IPB_GroupUnMap", "Top", 1920 )
3193 ok = VRSet("IPB_GroupUnMap", "Left", VRGet("CN_Users","Width") + 80 )
3194 ok = VRSet("IPB_GroupScript", "Top", 2520 )
3195 ok = VRSet("IPB_GroupScript", "Left", VRGet("CN_Users","Width") + 80 )
3196 ok = VRSet("IPB_GroupWellknown", "Top", 3120 )
3197 ok = VRSet("IPB_GroupWellknown", "Left", VRGet("CN_Users","Width") + 80 )
3198
3199 ok = VRset("CB_SmbGroupsOnly","Left", 20)
3200 ok = VRset("CB_SmbGroupsOnly","Top", VRGet("CN_Groups","Height")+120 )
3201
3202 ButtonDist= 1120
3203 ButtonNr = 6
3204 ButtonPos = format(max((VRget(MainWin,"Width")-ButtonDist*ButtonNr)/2,0),,0)
3205 ok = VRSEt("PB_RPC", "left",ButtonPos+ButtonDist*(ButtonNr-6))
3206 ok = VRSEt("PB_Save", "left",ButtonPos+ButtonDist*(ButtonNr-5))
3207 ok = VRSEt("PB_Refresh","left",ButtonPos+ButtonDist*(ButtonNr-4))
3208 ok = VRSEt("PB_Help", "left",ButtonPos+ButtonDist*(ButtonNr-3))
3209 ok = VRSEt("PB_About", "left",ButtonPos+ButtonDist*(ButtonNr-2))
3210 ok = VRSEt("PB_Exit", "left",ButtonPos+ButtonDist*(ButtonNr-1))
3211
3212 ok = VRSEt("PB_RPC", "width",ButtonDist-80)
3213 ok = VRSEt("PB_Save", "width",ButtonDist-80)
3214 ok = VRSEt("PB_Refresh","width",ButtonDist-80)
3215 ok = VRSEt("PB_Help", "width",ButtonDist-80)
3216 ok = VRSEt("PB_About", "width",ButtonDist-80)
3217 ok = VRSEt("PB_Exit", "width",ButtonDist-80)
3218
3219 /* check and empty event queue, trash spurious resize events */
3220 EventString = ''
3221 TrashedResize = 0
3222 do until EventString = 'nop'
3223 EventString = VREvent('N')
3224 if EventString <> 'nop' then do
3225 if EventString = 'CALL 'MainWin'_Resize' then TrashedResize = 1
3226 else interpret eventString
3227 end
3228 end
3229 if TrashedResize then CALL Main_Resize
3230 ok = VRSet(MainWin, "Painting", 1)
3231
3232 /* ok = VRset(MainWin,"Visible", 1) */
3233 IF options.!debug == 1 THEN say 'Main_Resize() done.'
3234return
3235
3236/*:VRX MapGroup_Close
3237*/
3238MapGroup_Close:
3239 call MapGroup_Fini
3240return
3241
3242/*:VRX MapGroup_Create
3243*/
3244MapGroup_Create:
3245 call MapGroup_Init
3246 CALL NLVSetText 'MapGroup', 'Caption', 60
3247 CALL NLVSetText 'PB_GroupMapOK', 'Caption', 2
3248 CALL NLVSetText 'PB_GroupMapCancel', 'Caption', 3
3249
3250 CALL NLVSetText 'DT_NTGroupname', 'Caption', 61
3251 CALL NLVSetText 'DT_NTGroupComment', 'Caption', 52
3252 CALL NLVSetText 'DT_NTRID', 'Caption', 62
3253 CALL NLVSetText 'DT_NTGroupType', 'Caption', 63
3254 CALL NLVSetText 'RB_NTGroupType_domain','Caption', 64
3255 CALL NLVSetText 'RB_NTGroupType_builtin','Caption', 65
3256 CALL NLVSetText 'RB_NTGroupType_local','Caption', 66
3257
3258 ok = VRSet("EF_NTGroupName","Value", GroupName.SelGNr)
3259 ok = VRSet("EF_NTRID","Value", GGID.SelGNr)
3260 NTGroupType = 'domain'
3261return
3262
3263/*:VRX MapGroup_Fini
3264*/
3265MapGroup_Fini:
3266 window = VRInfo( "Window" )
3267 call VRDestroy window
3268 drop window
3269return
3270/*:VRX MapGroup_Init
3271*/
3272MapGroup_Init:
3273 window = VRInfo( "Object" )
3274 if( \VRIsChildOf( window, "Notebook" ) ) then do
3275 call VRMethod window, "CenterWindow"
3276 call VRSet window, "Visible", 1
3277 call VRMethod window, "Activate"
3278 end
3279 drop window
3280return
3281
3282/*:VRX Page1_Create
3283*/
3284Page1_Create:
3285
3286Return
3287
3288/*:VRX Page1_Init
3289*/
3290Page1_Init:
3291 call _ContainerInit
3292return
3293
3294/*:VRX Page2_Create
3295*/
3296Page2_create:
3297
3298Return
3299/*:VRX Page2_init
3300*/
3301Page2_init:
3302
3303return
3304
3305/*:VRX Page3_Create
3306*/
3307Page3_create:
3308
3309Return
3310/*:VRX Page3_Init
3311*/
3312Page3_Init:
3313
3314return
3315
3316/*:VRX Page4_Create
3317*/
3318Page4_Create:
3319
3320Return
3321/*:VRX Page4_init
3322*/
3323Page4_init:
3324
3325return
3326
3327/*:VRX Page5_Create
3328*/
3329Page5_Create:
3330
3331return
3332
3333/*:VRX Page5_Init
3334*/
3335Page5_Init:
3336
3337return
3338
3339/*:VRX Paper_Init
3340*/
3341Paper_Init:
3342 ok = VRSet("IPB_Paper","Width" ,VRMethod( "Screen", "PixelsToTwips", 32 ))
3343 ok = VRSet("IPB_Paper","Height",VRMethod( "Screen", "PixelsToTwips", 32 ))
3344 ok = VRset("IPB_Paper","Left",VRget("GB_Main2","width")-420)
3345return
3346
3347/*:VRX PB_About_Click
3348*/
3349PB_About_Click:
3350 window = VRLoadSecondary( "About", "W" )
3351return
3352
3353/*:VRX PB_AboutOK_Click
3354*/
3355PB_AboutOK_Click:
3356 call About_Close
3357return
3358
3359/*:VRX PB_AddUserCancel_Click
3360*/
3361PB_AddUserCancel_Click:
3362 call AddUser_Close
3363return
3364
3365/*:VRX PB_AddUserOK_Click
3366*/
3367PB_AddUserOK_Click:
3368 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click started.'
3369 if VRGet("EF_username","Value") ="" then do
3370 Msg.type = "E"
3371 Msg.Text = NLVGetMessage( 101 )
3372 call _ShowMsg
3373 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3374 return
3375 end
3376 if VRGet("EF_password","Value") ="" & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do
3377 Msg.type = "E"
3378 Msg.Text = NLVGetMessage( 102 )
3379 call _ShowMsg
3380 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3381 return
3382 end
3383 if VRGet("EF_password_repeat","Value") ="" & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do
3384 Msg.type = "E"
3385 Msg.Text = NLVGetMessage( 103 )
3386 call _ShowMsg
3387 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3388 return
3389 end
3390
3391 if VRGet("EF_password","Value") <> VRGet("EF_password_repeat","Value") then do
3392 Msg.type = "E"
3393 Msg.Text = NLVGetMessage( 104 )
3394 call _ShowMsg
3395 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3396 return
3397 end
3398
3399 if length(VRGet("EF_password","Value")) < MinPWLength & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do
3400 Msg.type = "E"
3401 Msg.Text = NLVGetMessage( 117 )
3402 call _ShowMsg
3403 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3404 return
3405 end
3406
3407 if (substr(VRGet("DT_UID","Caption"),6) = VRGet("DDCB_GID","Value")) & (substr(VRGet("DT_UID","Caption"),6) < 65000) then do
3408 Msg.Type = "W"
3409 Msg.Text = NLVGetMessage(115)
3410 ok = _MsgYesNo()
3411 if ok = 2 then do
3412 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3413 return
3414 end
3415 end
3416
3417 if IsUnixUser then nx = UnixUserNr
3418 else do
3419 nx = Username.0 + 1
3420 Username.0 = nx
3421 end
3422 Username.nx = VRGet("EF_Username","Value")
3423 UID.nx = substr(VRGet("DT_UID","Caption"),6)
3424 GID.nx = VRGet("DDCB_GID","Value")
3425 password.nx = "*"
3426 loginclass.NX = '' /* dummy value */
3427 pwchange.NX = '0' /* dummy value */
3428 deact.NX = '0' /* dummy value */
3429 gecos.NX = VRGet("EF_GECOS","Value") /* Full name */
3430 home.NX = _PathStrkLIBC(VRGet("EF_Home","Value"))
3431 shell.NX = '/usr/sbin/nologin' /* dummy value */
3432 lmhash.NX = ""
3433 nthash.NX = ""
3434 flags.NX = ""
3435 lct.NX = ""
3436 Status.nx = ""
3437 call _MasterpasswdWrite
3438 call _PasswordDBRewrite
3439
3440 if pwd_mkdbRC = 0 then do
3441 if \VRGet("CB_UnixUserOnly","set") then do
3442 call _useraddsmb
3443 if SecondStage then do
3444 command = ""
3445 newflags = ""
3446 if VRGet("EF_Description","value") <> "" then command = ' --account-desc="'VRGet("EF_Description","value")'" '
3447 if VRGet("CB_Password_doesnt_expire","set") then newFlags = NewFlags||"X"
3448 if VRGet("CB_Deactivated","set") then newFlags = NewFlags||"D"
3449 if NewFlags <> "" then command = command||' -c "['NewFlags']"'
3450 say ' 'samba.!pdbeditexe' --user='Username.nx' --modify 'command' 'DebugLevel' 2>'samba.!error' 1>'samba.!msg
3451 address cmd samba.!pdbeditexe' --user='Username.nx' --modify 'command' 'DebugLevel' 2>'samba.!error' 1>'samba.!msg
3452
3453 if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */
3454 end
3455/* if GID.NX <> UID.NX then call _SmbGroupMembersSync GID.NX
3456 else call _SmbGroupMembersSync 513
3457 call _GroupWrite
3458 call _ContGroupsPopulate */
3459 end
3460 end
3461 call PB_Refresh_Click
3462
3463 call AddUser_Close
3464 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click done.'
3465return
3466
3467/*:VRX PB_ChooseHome_Click
3468*/
3469PB_ChooseHome_Click:
3470 TargetDir = _DirDialog("",Samba.!homes)
3471 if TargetDir = "" then return
3472 ok = VRSet("EF_Home","value", TargetDir)
3473 drop TargetDir
3474return
3475
3476/*:VRX PB_CreateHome_Click
3477*/
3478PB_CreateHome_Click:
3479 if translate(VRGet("EF_Home","Value")) = "\NONEXISTENT" | translate(VRGet("EF_Home","Value")) = "\DEV\NULL" then return
3480 ok = SysMkDir(VRGet("EF_Home","Value"))
3481 call EF_Home_Change
3482return
3483
3484/*:VRX PB_Exit_Click
3485*/
3486PB_Exit_Click:
3487 say 'start PB_Cancel_Click'
3488 Call Quit
3489 say 'done PB_Cancel_Click'
3490return
3491
3492/*:VRX PB_GroupAddCancel_Click
3493*/
3494PB_GroupAddCancel_Click:
3495 call AddGroup_Close
3496return
3497
3498/*:VRX PB_GroupAddOK_Click
3499*/
3500PB_GroupAddOK_Click:
3501 if \UnixGroupOnly then do
3502 if VRGet("EF_Comment","Value") <> "" then Comment = ' -C "'VRGet("EF_Comment","Value")'"'
3503 else Comment = ""
3504 address cmd samba.!netexe' rpc group add "'VRGet("EF_GroupName","Value")'" 'Comment' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3505 if RC <> 0 then call _SambaShowError
3506 else call _SambaShowMsg
3507 end
3508 else do
3509 if VRGet("CB_AutomaticGGID","set")
3510 then call _kLibcGroupAdd VRGet("EF_GroupName","Value") , _GetNextGID()
3511 else call _kLibcGroupAdd VRGet("EF_GroupName","Value") , VRget("EF_GGID","Value")
3512 call PB_Save_Click
3513 end
3514 call PB_Refresh_Click
3515 call AddGroup_Close
3516return
3517
3518/*:VRX PB_GroupMapCancel_Click
3519*/
3520PB_GroupMapCancel_Click:
3521 call MapGroup_Close
3522return
3523
3524/*:VRX PB_GroupMapOK_Click
3525*/
3526PB_GroupMapOK_Click:
3527 if VRGet("EF_NTGRoupComment","value") <> "" then Comment = ' comment="'VRGet("EF_NTGRoupComment","value")'"'
3528 else Comment = ""
3529/* net groupmap add rid=512 ntgroup="Domain Admins" unixgroup="root" type=domain */
3530
3531say address cmd samba.!netexe' groupmap add rid='VRGet("EF_NTRID","Value")' ntgroup="'VRGet("EF_NTGroupName","Value")'" unixgroup="'GroupName.SelGnr'" type='NTGroupType' 'Comment' 'debuglevel
3532 address cmd samba.!netexe' groupmap add rid='VRGet("EF_NTRID","Value")' ntgroup="'VRGet("EF_NTGroupName","Value")'" unixgroup="'GroupName.SelGnr'" type='NTGroupType' 'Comment' 'debuglevel' 2>'samba.!error' 1>'samba.!msg
3533 if RC <> 0 then call _SambaShowError
3534 else do
3535 call _SambaShowMsg
3536 blGusers = translate(Gusers.SelGnr,' ',',')
3537 do I = 1 to words(blGusers)
3538 address cmd samba.!netexe' rpc group addmem "'VRGet("EF_NTGroupName","Value")'" 'word(BlGusers,I)' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3539 if RC <> 0 then call _SambaShowError
3540 else call _SambaShowMsg
3541 say samba.!netexe' RC = 'RC
3542 end
3543 end
3544 call PB_Refresh_Click
3545 call MapGroup_Close
3546return
3547
3548/*:VRX PB_GroupMembersOK_Click
3549*/
3550PB_GroupMembersOK_Click:
3551 IF options.!debug == 1 THEN say 'PB_Group_MembersOK_Click started.'
3552 call Group_Members_Close
3553 IF options.!debug == 1 THEN say 'PB_Group_MembersOK_Click done.'
3554return
3555
3556/*:VRX PB_Help_Click
3557*/
3558PB_Help_Click:
3559 Msg.Title = VRGet("Main", "Caption")
3560 Msg.Type = "I"
3561 Msg.Text = "Not implemented"
3562 call _ShowMsg
3563return
3564
3565/*:VRX PB_JoinCancel_Click
3566*/
3567PB_JoinCancel_Click:
3568 call Join_Group_Close
3569return
3570
3571/*:VRX PB_JoinOK_Click
3572*/
3573PB_JoinOK_Click:
3574 ok = VRMethod( "LB_Groups", "GetSelectedStringList", SelGroups. )
3575 if SelGroups.0 = 0 then return
3576 do I = 1 to SelGroups.0
3577 ok = VRCopyFile(samba.!group, samba.!group'.bak')
3578 say samba.!netexe' rpc addmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3579 address cmd samba.!netexe' rpc group addmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3580 if RC <> 0 then do
3581 call _SambaShowError
3582 ok = VRCopyFile(samba.!group'.bak', samba.!group)
3583 end
3584 else call _SambaShowMsg
3585
3586/* call _SmbGroupMembersSync SelGroups.I
3587 call _GroupWrite */
3588 end
3589 call Join_Group_Close
3590 call PB_Refresh_Click
3591return
3592
3593/*:VRX PB_LeaveCancel_Click
3594*/
3595PB_LeaveCancel_Click:
3596 call Leave_Group_Close
3597return
3598
3599/*:VRX PB_LeaveOK_Click
3600*/
3601PB_LeaveOK_Click:
3602 ok = VRMethod( "LB_LeaveGroups", "GetSelectedStringList", SelGroups. )
3603 if SelGroups.0 = 0 then return
3604 do I = 1 to SelGroups.0
3605 ok = VRCopyFIle(samba.!group, samba.!group'.bak')
3606 say samba.!netexe' rpc delmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3607 address cmd samba.!netexe' rpc group delmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3608 if RC <> 0 then do
3609 call _SambaShowError
3610 ok = VRCopyFile(samba.!group'.bak', samba.!group)
3611 end
3612 else call _SambaShowMsg
3613/* call _SmbGroupMembersSync SelGroups.I
3614 call _GroupWrite */
3615 end
3616 call Leave_Group_Close
3617 call PB_Refresh_Click
3618return
3619
3620/*:VRX PB_LOGIN_CANCEL_Click
3621*/
3622PB_LOGIN_CANCEL_Click:
3623 say " Login Abort"
3624 call SW_LOGIN_Close
3625 exit 0
3626return
3627
3628/*:VRX PB_LOGIN_OK_Click
3629*/
3630PB_LOGIN_OK_Click:
3631 IF options.!debug == 1 THEN say " SW_LOGIN OK started"
3632 Credentials.!Username = VRGet("EF_LoginUser","Value")
3633 Credentials.!Password = VRGet("EF_LoginPassword","Value")
3634
3635 if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0
3636 then UserCred = '--user='Credentials.!username'%'Credentials.!password
3637 else UserCred = '--user='Credentials.!username'%%'Credentials.!password
3638
3639 Call SW_LOGIN_Close
3640 IF options.!debug == 1 THEN say " SW_LOGIN OK done"
3641return
3642
3643/*:VRX PB_pdbeditConsole_Click
3644*/
3645PB_pdbeditConsole_Click:
3646 Buttons.1 = NLVGetMessage(2)
3647 Buttons.2 = NLVGetMessage(3)
3648 Buttons.0 = 2
3649 command = ' --account-desc= --fullname --homedir= --drive= --script= --profile= --domain= -c "[NDHLX]"'
3650 id = VRPrompt( VRWindow(), 'pdbedit --user='Username.CurUserNr' --modify', "command", "pdbedit Console", "Buttons.", buttons.1, buttons.2 )
3651 if id = 2 then return
3652 say samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'command' 'DebugLevel' 2>'samba.!error
3653 address cmd samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'command' 'DebugLevel' 2>'samba.!error
3654 if RC <> 0 then call _SambaShowError
3655 call _UserPropertiesGet Username.CurUserNr
3656return
3657
3658/*
3659Settable account flags
3660 N: No password required
3661 D: Account disabled
3662 H: Home directory required
3663 L: Automatic Locking
3664 X: Password does not expire
3665
3666Account Types:
3667 U: Regular user account
3668 T: Temporary duplicate of other account
3669 M: MNS logon user account
3670 W: Workstation Trust Account
3671 S: Server Trust Account
3672 I: Domain Trust Account
3673
3674 */
3675/*:VRX PB_PolReset_Click
3676*/
3677PB_PolReset_Click:
3678 say samba.!pdbeditexe' --policies-reset 'DebugLevel' 1>'samba.!msg
3679 address cmd samba.!pdbeditexe' --policies-reset 'DebugLevel' 1>'samba.!msg
3680 call _SambaShowMsg "description"
3681return
3682
3683/*:VRX PB_PolUpdate_Click
3684*/
3685PB_PolUpdate_Click:
3686 say samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" -C 'VRGet("EF_PolValue","Value")' 'DebugLevel' 1>'samba.!msg
3687 address cmd samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" -C 'VRGet("EF_PolValue","Value")' 'DebugLevel' 1>'samba.!msg
3688 call _SambaShowMsg "description"
3689return
3690
3691/*:VRX PB_Refresh_Click
3692*/
3693PB_Refresh_Click:
3694 call _Refresh
3695return
3696
3697/*:VRX PB_RPC_Click
3698*/
3699PB_RPC_Click:
3700 Buttons.1 = NLVGetMessage(2)
3701 Buttons.2 = NLVGetMessage(3)
3702 Buttons.0 = 2
3703 command = 'group'
3704 id = VRPrompt( VRWindow(), "net rpc", "command", "net rpc Console", "Buttons.", buttons.1, buttons.2 )
3705 if id = 2 then return
3706 say samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3707 address cmd samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3708 if RC <> 0 then call _SambaShowError; else call _SambaShowMsg
3709 call PB_Refresh_Click
3710return
3711
3712/*:VRX PB_Save_Click
3713*/
3714PB_Save_Click:
3715 call _MasterpasswdWrite
3716 call _GroupWrite
3717 call _PasswordDBRewrite
3718 call _SmbUserMapWrite
3719return
3720
3721/*:VRX PB_upCancel_Click
3722*/
3723PB_upCancel_Click:
3724 call UserProperties_Close
3725return
3726
3727/*:VRX PB_upSave_Click
3728*/
3729PB_upSave_Click:
3730/* U: Regular user account
3731 T: Temporary duplicate of other account
3732 M: MNS logon user account
3733 W: Workstation Trust Account
3734 S: Server Trust Account
3735 I: Domain Trust Account */
3736
3737 /* we mask out flags that cannot be modified anyway here */
3738 CurFlags = translate(CurFlags,' ','UTMWSI')
3739
3740 if VRGet("CB_upResetLogonHours", "set") then newcommand = newcommand||' -Z'
3741
3742 say samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'newcommand' -c "['CurFlags']" 'DebugLevel' 2>'samba.!error /* ' 1>'samba.!msg */
3743 address cmd samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'newcommand' -c "['CurFlags']" 'DebugLevel' 2>'samba.!error /* ' 1>'samba.!msg */
3744 if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */
3745
3746 else do
3747 if VRGet("EF_upPassword","Value") <> "" | VRGet("EF_upPassword_repeat","Value") <> "" then do /* Password change! */
3748 if VRGet("EF_upPassword","Value") <> VRGet("EF_upPassword_repeat","Value") then do
3749 Msg.type = "E"
3750 Msg.Text = NLVGetMessage( 104 )
3751 call _ShowMsg
3752 return
3753 end
3754 else do
3755 if length(VRGet("EF_upPassword","Value")) < MinPWLength then do
3756 Msg.type = "E"
3757 Msg.Text = NLVGetMessage( 117 )
3758 call _ShowMsg
3759 return
3760 end
3761 else do
3762 pwdfile = TempDir'newpwd'
3763 call lineout pwdfile, VRGet("EF_upPassword","value")
3764 call lineout pwdfile, VRGet("EF_upPassword","value")
3765 ok = stream(pwdfile,"c","close")
3766 say samba.!smbpasswdexe' -a 'Username.CurUserNr' -s <'pwdfile' 2>'samba.!error
3767 address cmd samba.!smbpasswdexe' -a 'Username.CurUserNr' -s <'pwdfile' 2>'samba.!error' 1>'samba.!msg
3768 smbpasswdrc = rc
3769 if rc <> 0 then call _SambaShowError
3770 else call _SambaShowMsg
3771 ok = SysFileDelete(pwdfile)
3772 if SwatAuth then do
3773 /* we always remove the old swat */
3774 say ' 'samba.!htpasswdexe' -D "'swatusers'" 'Username.CurUserNr
3775 address cmd samba.!htpasswdexe' -D "'swatusers'" 'Username.CurUserNr /* ' 2>'samba.!error' 1>'samba.!msg
3776 if rc <> 0 then call _SambaShowError; else call _SambaShowMsg */
3777
3778 if VRGet("CB_upSWAT_Allowed","Set") then do
3779 if VRFileExists(swatusers) then cFlag = ""; else cFlag="c"
3780 say ' 'samba.!htpasswdexe' -b'cFLag' "'swatusers'" 'Username.CurUserNr' **********'
3781 address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" 'Username.CurUserNr' 'VRGet("EF_upPassword","value")' 2>'samba.!error' 1>'samba.!msg
3782 if rc <> 0 then call _SambaShowError
3783 else call _SambaShowMsg
3784 end
3785 end
3786 end
3787 end
3788 end
3789 if pos("--fullname", newcommand) > 0 & Settings.!SyncFullName = 1 then do
3790 parse var newcommand dummy '--fullname="'NewGECOS'"' dummy
3791 GECOS.CurUserNr = NewGECOS
3792 SyncedFullName = 1
3793 end
3794 call UserProperties_Close
3795 end
3796return
3797
3798/*:VRX PushbackAll
3799*/
3800PushbackAll:
3801 Pages = 4
3802 /* Tab distance from top */
3803 TabTop = 20
3804 TabWidth = VRMethod( "Screen", "PixelsToTwips", 78 )
3805 TabHeight= VRMethod( "Screen", "PixelsToTwips", 24 )
3806
3807 /* Page Position */
3808 PageLeft = 120
3809 PageTop = PageLeft + TabTop + 330
3810
3811 /* Page size */
3812 PageHeight = 3000
3813 PageWidth = 3000
3814 ok = VRset("DT_PageName", "Caption", "")
3815 ok = VRSet("GB_Main","Left", 0)
3816 ok = VRSet("GB_Main","Top", TabTop+230)
3817 do I = 1 to Pages
3818 ok = VRSet("Page_"I,"BackColor", "<default>")
3819 ok = VRSet("TAB_"I,"Top", TabTop)
3820 ok = VRSet("TAB_"I,"PicturePath","#2"||I||";#2"||I)
3821 ok = VRSet("TAB_"I,"Left",TabWidth*(I-1)+PageLeft)
3822 ok = VRSet("TAB_"I,"Width",TabWidth)
3823 ok = VRSet("TAB_"I,"Height",TabHeight)
3824 ok = VRSet("Page_"I,"Height", max(PageHeight,VRget("GB_Main2","Height")-600))
3825 ok = VRSet("Page_"I,"Width", max(PageWidth,VRget("GB_Main2","Width")-450))
3826 ok = VRSet("Page_"I,"Left", PageLeft)
3827 ok = VRSet("Page_"I,"Top", PageTop)
3828 ok = VRSet("Page_"I,"Visible", 0)
3829 end
3830return
3831
3832/*:VRX Quit
3833*/
3834Quit:
3835 if VRGet("Main","WindowState") = "Maximized"|,
3836 VRGet("Main","WindowState") = "Minimized" then ok = VRMethod("Main", "Restore")
3837 call _IniWrite
3838 ok = VRREdirectStdio("OFF")
3839 call _SambaFinish
3840 ok = SysFileDelete(smbdoutput)
3841 if VRParseFileName(samba.!smbpasswd,"DP")||'\' = TempDir then do
3842 ok = SysFileDelete(samba.!smbpasswd)
3843 end
3844 window = VRWindow()
3845 call VRSet window, "Shutdown", 1
3846 drop window
3847return
3848
3849/*:VRX RB_NTGroupType_builtin_Click
3850*/
3851RB_NTGroupType_builtin_Click:
3852 NTGroupType = 'builtin'
3853return
3854
3855/*:VRX RB_NTGroupType_domain_Click
3856*/
3857RB_NTGroupType_domain_Click:
3858 NTGroupType = 'domain'
3859return
3860
3861/*:VRX RB_NTGroupType_local_Click
3862*/
3863RB_NTGroupType_local_Click:
3864 NTGroupType = 'local'
3865return
3866
3867/*:VRX SW_LOGIN_Close
3868*/
3869SW_LOGIN_Close:
3870 call SW_LOGIN_Fini
3871return
3872
3873/*:VRX SW_LOGIN_Create
3874*/
3875SW_LOGIN_Create:
3876 call SW_LOGIN_Init
3877 CALL NLVSetText 'SW_LOGIN', 'Caption', 31
3878 CALL NLVSetText 'DT_LoginUser', 'Caption', 32
3879 CALL NLVSetText 'DT_LoginPassword','Caption', 33
3880 CALL NLVSetText 'PB_LOGIN_OK', 'Caption', 2
3881 CALL NLVSetText 'PB_LOGIN_CANCEL', 'Caption', 3
3882
3883 if Credentials.!Username = ""
3884 then ok = VRSet("EF_LoginUser","Value", value("USER",,"OS2ENVIRONMENT"))
3885 else ok = VRSet("EF_LoginUser","Value", Credentials.!Username)
3886
3887 if \_UserIsValid(VRGet("EF_LoginUser","Value")) & value("USER",,"OS2ENVIRONMENT") <> "" then do
3888 Msg.Title =VRGet("Main", "caption")
3889 Msg.Type = "E"
3890 Msg.Text = NLVGetMessage(111, VRGet("EF_LoginUser","Value"))
3891 call _ShowMsg
3892 ok = VRSet("EF_LoginUser","Value","root")
3893 end
3894
3895 if VRGet("EF_LoginUser","Value") <> "" then ok = VRMethod("EF_LoginPassword","Setfocus")
3896return
3897
3898/*:VRX SW_LOGIN_Fini
3899*/
3900SW_LOGIN_Fini:
3901 window = VRInfo( "Window" )
3902 call VRDestroy window
3903 drop window
3904return
3905/*:VRX SW_LOGIN_Init
3906*/
3907SW_LOGIN_Init:
3908 window = VRInfo( "Object" )
3909 if( \VRIsChildOf( window, "Notebook" ) ) then do
3910 call VRMethod window, "CenterWindow"
3911 call VRSet window, "Visible", 1
3912 call VRMethod window, "Activate"
3913 end
3914 drop window
3915return
3916
3917/*:VRX TAB_1_Click
3918*/
3919TAB_1_Click:
3920 call Activate 1
3921return
3922
3923/*:VRX TAB_2_Click
3924*/
3925TAB_2_Click:
3926 call Activate 2
3927return
3928
3929/*:VRX TAB_3_Click
3930*/
3931TAB_3_Click:
3932 call Activate 3
3933return
3934
3935/*:VRX TAB_4_Click
3936*/
3937TAB_4_Click:
3938 call Activate 4
3939return
3940
3941/*:VRX TAB_5_Click
3942*/
3943TAB_5_Click:
3944 call Activate 5
3945return
3946
3947/*:VRX UserProperties_Close
3948*/
3949UserProperties_Close:
3950 call UserProperties_Fini
3951 if SyncedFullName = 1 | SyncedPrimGID = 1 then call PB_Save_Click
3952 call PB_Refresh_Click
3953return
3954
3955/*:VRX UserProperties_Create
3956*/
3957UserProperties_Create:
3958 call UserProperties_Init
3959 CALL NLVSetText 'UserProperties', 'Caption', 120
3960
3961 upTabWidth = VRMethod( "Screen", "PixelsToTwips", 136 )
3962 upTabHeight= VRMethod( "Screen", "PixelsToTwips", 24 )
3963
3964 ok = VRset("IPB_Accountflags","Width", upTabWidth)
3965 ok = VRset("IPB_Profile","Width", upTabWidth)
3966 ok = VRset("IPB_Memberships","Width", upTabWidth)
3967
3968 ok = VRset("IPB_Accountflags","Top", 40)
3969 ok = VRset("IPB_Profile", "Top", 40)
3970 ok = VRset("IPB_Memberships", "Top", 40)
3971
3972 ok = VRset("IPB_Accountflags","Left", upTabWidth*0+40)
3973 ok = VRset("IPB_Profile", "Left", upTabWidth*1+40)
3974 ok = VRset("IPB_Memberships", "Left", upTabWidth*2+40)
3975
3976 ok = VRset("IPB_Accountflags","Height", upTabHeight)
3977 ok = VRset("IPB_Profile", "Height", upTabHeight)
3978 ok = VRset("IPB_Memberships", "Height", upTabHeight)
3979
3980 CALL NLVSetText 'PB_upSave', 'Caption', 10
3981 CALL NLVSetText 'PB_upCancel', 'Caption', 3
3982 ok = VRSet("PB_pdbeditconsole",'Caption', "pdbedit "||word(NLVGetMessage(23),2))
3983
3984 CALL NLVSetText 'DT_upAccountType', 'Caption', 55
3985 CALL NLVSetText 'CB_upNoPassword', 'Caption', 20
3986 CALL NLVSetText 'DT_upPassword', 'Caption', 33
3987 CALL NLVSetText 'DT_upPassword_Repeat', 'Caption', 43
3988
3989 CALL NLVSetText 'CB_upMust_change_password', 'Caption', 46
3990 CALL NLVSetText 'CB_upCannot_change_password', 'Caption', 47
3991 CALL NLVSetText 'CB_upPassword_doesnt_expire', 'Caption', 48
3992 CALL NLVSetText 'CB_upDeactivated', 'Caption', 49
3993 CALL NLVSetText 'CB_upResetLogonHours', 'Caption', 54
3994 CALL NLVSetText 'CB_upSWAT_Allowed', 'Caption', 35
3995
3996 ok = VRSet('CB_upSWAT_Allowed',"Enabled",swatAuth)
3997
3998 CALL NLVSetText 'DT_upGroups', 'Caption', 56
3999 CALL NLVSetText 'CB_EditableFieldsOnly', 'Caption', 45
4000
4001 upNrFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(130))
4002 upTypeFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(57))
4003 upValueFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(58))
4004 upCommandFH= VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(59))
4005
4006 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upNrFH, "Visible", 0)
4007 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upTypeFH, "ReadOnly", 1)
4008 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upValueFH, "ReadOnly", 0)
4009 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upCommandFH, "ReadOnly", 1)
4010 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upCommandFH, "Visible", 0)
4011
4012 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "Selected." )
4013 if Selected.0 = 0 then return
4014 CurUserNr = VRMethod("CN_Users","GetFieldData", Selected.1, NrFH)
4015 call IPB_AccountFlags_Click
4016
4017 ok = VRMethod("PB_upCancel", "SetFocus" )
4018
4019 SyncedPrimGID = 0
4020 SyncedFullName = 0
4021
4022 MinPWLength = _PolicyGet("min password length")
4023
4024 call _UserPropertiesGet Username.CurUserNr
4025 newcommand = ""
4026return
4027
4028/*:VRX UserProperties_Fini
4029*/
4030UserProperties_Fini:
4031 window = VRInfo( "Window" )
4032 call VRDestroy window
4033 drop window
4034return
4035/*:VRX UserProperties_Init
4036*/
4037UserProperties_Init:
4038 window = VRInfo( "Object" )
4039 if( \VRIsChildOf( window, "Notebook" ) ) then do
4040 call VRMethod window, "CenterWindow"
4041 call VRSet window, "Visible", 1
4042 call VRMethod window, "Activate"
4043 end
4044 drop window
4045return
4046
Note: See TracBrowser for help on using the repository browser.