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

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

GUI-Tools: SmbUsers: Change machine account to capital letters

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