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

Last change on this file since 569 was 569, checked in by Herwig Bauernfeind, 14 years ago

GUI-Tools: SMBUSERS: master.passwd password support

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