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

Last change on this file since 333 was 333, checked in by Herwig Bauernfeind, 16 years ago

GUI-Tools: Fix problem in smbusers

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