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

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

GUI-Tools: SmbUsers: Fix encrypted password option

File size: 143.9 KB
Line 
1/*:VRX Main
2*/
3/* Main
4*/
5Main:
6/* Process the arguments.
7 Get the parent window.
8*/
9 parse source . calledAs .
10 parent = ""
11 argCount = arg()
12 argOff = 0
13 if( calledAs \= "COMMAND" )then do
14 if argCount >= 1 then do
15 parent = arg(1)
16 argCount = argCount - 1
17 argOff = 1
18 end
19 end; else do
20 call VROptions 'ImplicitNames'
21 call VROptions 'NoEchoQuit'
22 end
23 InitArgs.0 = argCount
24 if( argCount > 0 )then do i = 1 to argCount
25 InitArgs.i = arg( i + argOff )
26 end
27 drop calledAs argCount argOff
28
29/* Load the windows
30*/
31 call VRInit
32 parse source . . spec
33 _VREPrimaryWindowPath = ,
34 VRParseFileName( spec, "dpn" ) || ".VRW"
35 _VREPrimaryWindow = ,
36 VRLoad( parent, _VREPrimaryWindowPath )
37 drop parent spec
38 if( _VREPrimaryWindow == "" )then do
39 call VRMessage "", "Cannot load window:" VRError(), ,
40 "Error!"
41 _VREReturnValue = 32000
42 signal _VRELeaveMain
43 end
44
45/* Process events
46*/
47 call Init
48 signal on halt
49 do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
50 _VREEvent = VREvent()
51 interpret _VREEvent
52 end
53_VREHalt:
54 _VREReturnValue = Fini()
55 call VRDestroy _VREPrimaryWindow
56_VRELeaveMain:
57 call VRFini
58exit _VREReturnValue
59
60VRLoadSecondary:
61 __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
62 if __vrlsWait then do
63 call VRFlush
64 end
65 __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
66 if __vrlsHWnd = '' then signal __vrlsDone
67 if __vrlsWait \= 1 then signal __vrlsDone
68 call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
69 __vrlsTmp = __vrlsWindows.0
70 if( DataType(__vrlsTmp) \= 'NUM' ) then do
71 __vrlsTmp = 1
72 end
73 else do
74 __vrlsTmp = __vrlsTmp + 1
75 end
76 __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
77 __vrlsWindows.0 = __vrlsTmp
78 do while( VRIsValidObject( VRWindow() ) = 1 )
79 __vrlsEvent = VREvent()
80 interpret __vrlsEvent
81 end
82 __vrlsTmp = __vrlsWindows.0
83 __vrlsWindows.0 = __vrlsTmp - 1
84 call VRWindow __vrlsWindows.__vrlsTmp
85 __vrlsHWnd = ''
86__vrlsDone:
87return __vrlsHWnd
88
89/*:VRX __VXREXX____APPENDS__
90*/
91__VXREXX____APPENDS__:
92/*
93#append U:\Develop\Samba\guitools-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 right(VRGet("EF_Username","Value"),1) = "$" then do
1886 /* ok = VRSet("EF_Username","Value",translate(VRGet("EF_Username","Value"))) */
1887 ok = VRset("CB_UnixUserOnly","set", 0)
1888 ok = VRset("CB_MachineAccount","set", 1)
1889 ok = VRSet("CB_NoPassword","set", 0)
1890 ok = VRSet("CB_NoPassword","Enabled", 0)
1891 ok = VRSet("EF_Password","BackColor", "PaleGray")
1892 ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray")
1893 ok = VRSet("EF_Password","Enabled", 0)
1894 ok = VRSet("EF_Password_Repeat","Enabled", 0)
1895 ok = VRSet("CB_Must_Change_Password","Enabled", 0)
1896 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1897 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1898
1899 end
1900 else do
1901 ok = VRset("CB_MachineAccount","set", 0)
1902 ok = VRSet("CB_NoPassword","Enabled", 1)
1903 call CB_NoPassword_Click
1904 end
1905return
1906
1907/*:VRX CB_Must_change_password_Click
1908*/
1909CB_Must_change_password_Click:
1910 SecondStage = (SecondStage | VRGet("CB_Must_change_password","set"))
1911 if VRGet("CB_Must_Change_Password","set") then do
1912 ok = VRSet("CB_Cannot_change_password","Set", 0)
1913 ok = VRSet("CB_Password_doesnt_expire","Set", 0)
1914 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1915 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1916 end
1917 else do
1918 ok = VRSet("CB_Cannot_change_password","Enabled", 1)
1919 ok = VRSet("CB_Password_doesnt_expire","Enabled", 1)
1920 end
1921return
1922
1923/*:VRX CB_NoHome_Click
1924*/
1925CB_NoHome_Click:
1926 ok = VRSet("EF_Home","Enabled",\VRGet("CB_NoHome","set"))
1927 ok = VRset("PB_CreateHome","Enabled",\VRGet("CB_NoHome","set"))
1928 ok = VRSet("PB_ChooseHome","Enabled",\VRGet("CB_NoHome","set"))
1929 if VRGet("CB_NoHome","set") then ok = VRSet("EF_HOME","Value", "\nonexistent")
1930return
1931
1932/*:VRX CB_NoPassword_Click
1933*/
1934CB_NoPassword_Click:
1935 if VRGet("CB_NoPassword","set") then do
1936 ok = VRSet("EF_Password","BackColor", "PaleGray")
1937 ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray")
1938 ok = VRSet("EF_Password","Enabled", 0)
1939 ok = VRSet("EF_Password_Repeat","Enabled", 0)
1940 ok = VRSet("CB_Must_Change_Password","Enabled", 0)
1941 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1942 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1943 ok = VRSet("CB_SWAT_Allowed","Enabled", 0)
1944 end
1945 else do
1946 ok = VRSet("EF_Password","BackColor", "<default>")
1947 ok = VRSet("EF_Password_Repeat","BackColor", "<default>")
1948 ok = VRSet("EF_Password","Enabled", 1)
1949 ok = VRSet("EF_Password_Repeat","Enabled", 1)
1950 ok = VRSet("CB_Must_Change_Password","Enabled", 1)
1951 ok = VRSet("CB_Cannot_change_password","Enabled", 1)
1952 ok = VRSet("CB_Password_doesnt_expire","Enabled", 1)
1953 ok = VRSet("CB_SWAT_Allowed","Enabled", 1)
1954 end
1955return
1956
1957/*:VRX CB_Password_doesnt_expire_Click
1958*/
1959CB_Password_doesnt_expire_Click:
1960 SecondStage = (SecondStage | VRGet("CB_Password_doesnt_expire","set"))
1961return
1962
1963/*:VRX CB_SmbGroupsOnly_Click
1964*/
1965CB_SmbGroupsOnly_Click:
1966 settings.!SmbGroupsOnly = VRGet("CB_SmbGroupsOnly","Set")
1967 call _ContGroupsPopulate
1968return
1969
1970/*:VRX CB_SmbOnly_Click
1971*/
1972CB_SmbOnly_Click:
1973 settings.!SmbOnly = VRGet("CB_SmbOnly","Set")
1974 call _ContainerPopulate
1975return
1976
1977/*:VRX CB_SWAT_Allowed_Click
1978*/
1979CB_SWAT_Allowed_Click:
1980 if right(VRGet("EF_Username","Value"),1) = "$" then do
1981 /* ok = VRSet("EF_Username","Value",translate(VRGet("EF_Username","Value"))) */
1982 ok = VRset("CB_UnixUserOnly","set", 0)
1983 ok = VRset("CB_MachineAccount","set", 1)
1984 ok = VRSet("CB_NoPassword","set", 0)
1985 ok = VRSet("CB_NoPassword","Enabled", 0)
1986 ok = VRSet("EF_Password","BackColor", "PaleGray")
1987 ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray")
1988 ok = VRSet("EF_Password","Enabled", 0)
1989 ok = VRSet("EF_Password_Repeat","Enabled", 0)
1990 ok = VRSet("CB_Must_Change_Password","Enabled", 0)
1991 ok = VRSet("CB_Cannot_change_password","Enabled", 0)
1992 ok = VRSet("CB_Password_doesnt_expire","Enabled", 0)
1993
1994 end
1995 else do
1996 ok = VRset("CB_MachineAccount","set", 0)
1997 ok = VRSet("CB_NoPassword","Enabled", 1)
1998 call CB_NoPassword_Click
1999 end
2000return
2001
2002/*:VRX CB_SyncFullName_Click
2003*/
2004CB_SyncFullName_Click:
2005 settings.!SyncFullName = VRGet("CB_SyncFullName","set")
2006return
2007
2008/*:VRX CB_SyncPrimGID_Click
2009*/
2010CB_SyncPrimGID_Click:
2011 settings.!SyncPrimGID = VRGet("CB_SyncPrimGID","set")
2012return
2013
2014/*:VRX CB_UnixGroupOnly_Click
2015*/
2016CB_UnixGroupOnly_Click:
2017 UnixGroupOnly = VRGet("CB_UnixGroupOnly","set")
2018 ok = VRSet("EF_Comment","Enabled", \VRget("CB_UnixGroupOnly","Set"))
2019 if \VRget("CB_UnixGroupOnly","Set") then ok = VRSet("EF_Comment","BackColor","<default>")
2020 else ok = VRSet("EF_Comment","BackColor","PaleGray")
2021return
2022
2023/*:VRX CB_UnixUserOnly_Click
2024*/
2025CB_UnixUserOnly_Click:
2026 if VRGet("CB_UnixUserOnly","set") then do
2027 ok = VRSet("CB_NoPassword","set",1)
2028 call CB_NoPassword_Click
2029 ok = VRSet("EF_Description", "BackColor", "PaleGray")
2030 ok = VRSet("EF_Description", "Enabled", 0)
2031 end
2032 else do
2033 ok = VRSet("EF_Description", "BackColor", "<default>")
2034 ok = VRSet("EF_Description", "Enabled", 1)
2035 ok = VRSet("CB_NoPassword","set",0)
2036 call CB_NoPassword_Click
2037 end
2038return
2039
2040/*:VRX CB_upCannot_change_password_Click
2041*/
2042CB_upCannot_change_password_Click:
2043
2044return
2045
2046/*:VRX CB_upDeactivated_Click
2047*/
2048CB_upDeactivated_Click:
2049 CurFlags = _SetFlag(CurFlags, VRGet("CB_upDeactivated","set"), 'D')
2050return
2051
2052/*:VRX CB_upMust_change_password_Click
2053*/
2054CB_upMust_change_password_Click:
2055
2056return
2057
2058/*:VRX CB_upNoPassword_Click
2059*/
2060CB_upNoPassword_Click:
2061 CurFlags = _SetFlag(CurFlags, VRGet("CB_upNoPassword","set"), 'N')
2062 if VRGet("CB_upNoPassword","set") then do
2063 ok = VRSet("EF_upPassword","value","")
2064 ok = VRSet("EF_upPassword_Repeat","value","")
2065 ok = VRSet("DT_upPassword","Enabled",0)
2066 ok = VRSet("DT_upPassword_Repeat","Enabled",0)
2067 ok = VRSet("EF_upPassword","Enabled",0)
2068 ok = VRSet("EF_upPassword_Repeat","Enabled",0)
2069 ok = VRSet("EF_upPassword","BackColor", "PaleGray")
2070 ok = VRSet("EF_upPassword_Repeat","BackColor", "PaleGray")
2071 end
2072 else do
2073 ok = VRSet("DT_upPassword","Enabled",1)
2074 ok = VRSet("DT_upPassword_Repeat","Enabled",1)
2075 ok = VRSet("EF_upPassword","Enabled",1)
2076 ok = VRSet("EF_upPassword_Repeat","Enabled",1)
2077 ok = VRSet("EF_upPassword","BackColor", "<default>")
2078 ok = VRSet("EF_upPassword_Repeat","BackColor", "<default>")
2079 end
2080return
2081
2082/*:VRX CB_upPassword_doesnt_expire_Click
2083*/
2084CB_upPassword_doesnt_expire_Click:
2085 CurFlags = _SetFlag(CurFlags, VRGet("CB_upPassword_doesnt_expire","set"), 'X')
2086return
2087
2088/*:VRX CB_upSWAT_Allowed_Click
2089*/
2090CB_upSWAT_Allowed_Click:
2091 swatchanged = 1
2092return
2093
2094/*:VRX CB_WriteMasterPwd_Click
2095*/
2096CB_WriteMasterPwd_Click:
2097 settings.!WriteMasterPwd = VRGet("CB_WriteMasterPwd","set")
2098return
2099
2100/*:VRX CN_Groups_ContextMenu
2101*/
2102CN_Groups_ContextMenu:
2103 if VRInfo("Top") < 1325 & VRGet("CN_Groups", "View") = "Detail" then call _ColumnsMenu "CN_Groups"
2104 else ok = VRMethod( "Contextmenu_Group", "Popup", , , "", "PositionOnItem" )
2105return
2106
2107/*:VRX CN_Groups_DoubleClick
2108*/
2109CN_Groups_DoubleClick:
2110 call Contextmenu_GroupMembers_Click
2111return
2112
2113/*:VRX CN_Groups_EndEdit
2114*/
2115CN_Groups_EndEdit:
2116call beep 880, 20
2117 GRH = VRInfo("Record")
2118
2119 /* write back all editable field to the stems */
2120 call _GroupRecWritebackToStems
2121
2122return
2123
2124/*:VRX CN_UserProperties_BeginEdit
2125*/
2126CN_UserProperties_BeginEdit:
2127 drop NewupValue
2128 drop OldupValue
2129 upRH = VRInfo("Record")
2130 OldupValue = VRMethod("CN_UserProperties","GetFieldData", upRH, upValueFH)
2131 say OldupValue
2132return
2133
2134/*:VRX CN_UserProperties_EndEdit
2135*/
2136CN_UserProperties_EndEdit:
2137 upRH = VRInfo("Record")
2138 NewupValue = VRMethod("CN_UserProperties","GetFieldData", upRH, upValueFH)
2139 say NewupValue
2140 if OldUpValue <> NewupValue then do
2141 newcommand = newcommand||' 'VRMethod("CN_UserProperties","GetFieldData", upRH,upCommandFH)||'"'NewupValue'"'
2142 say "New command: "newcommand
2143 end
2144return
2145
2146/*:VRX CN_Users_Click
2147*/
2148CN_Users_Click:
2149 if VRInfo("Top") < 1325 & VRGet("CN_Users", "View") = "Detail" then return
2150return
2151
2152/*:VRX CN_Users_ContextMenu
2153*/
2154CN_Users_ContextMenu:
2155 say VRInfo("top")
2156 if VRInfo("Top") < 1325 & VRGet("CN_users", "View") = "Detail" then call _ColumnsMenu "CN_users"
2157 else do
2158 RH = VRInfo("Record")
2159 if RH <> "" then do
2160 CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH)
2161 ok = VRset("Contextmenu_UserProperties", "Enabled", (CurFlags <> ""))
2162 ok = VRMethod( "Contextmenu_user", "Popup", , , "", "PositionOnItem" )
2163 end
2164 end
2165return
2166
2167/*:VRX CN_Users_DoubleClick
2168*/
2169CN_Users_DoubleClick:
2170 if VRInfo("Top") < 340 & VRGet("CN_Users", "View") = "Detail" then return
2171 say 'CN_Users_DoubleClick() started'
2172 RH = VRInfo("Record")
2173 CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH)
2174 if CurFlags <> "" then window = VRLoadSecondary( "UserProperties", "W" )
2175 say 'CN_Users_DoubleClick() done'
2176return
2177
2178/*:VRX CN_Users_EndEdit
2179*/
2180CN_Users_EndEdit:
2181 if VRInfo("Top") < 340 & VRGet("CN_Users", "View") = "Detail" then do
2182 say VRInfo("Object")
2183 return
2184 end
2185 call beep 880, 20
2186 RH = VRInfo("Record")
2187 say "RH="RH
2188
2189 /* write back all editable field to the stems */
2190 call _UserRecWritebackToStems
2191return
2192
2193/*:VRX Columns_01_Click
2194*/
2195Columns_01_Click:
2196 call _ColumnShow
2197return
2198
2199/*:VRX Columns_02_Click
2200*/
2201Columns_02_Click:
2202 call _ColumnShow
2203return
2204
2205/*:VRX Columns_03_Click
2206*/
2207Columns_03_Click:
2208 call _ColumnShow
2209return
2210
2211/*:VRX Columns_04_Click
2212*/
2213Columns_04_Click:
2214 call _ColumnShow
2215return
2216
2217/*:VRX Columns_05_Click
2218*/
2219Columns_05_Click:
2220 call _ColumnShow
2221return
2222
2223/*:VRX Columns_06_Click
2224*/
2225Columns_06_Click:
2226 call _ColumnShow
2227return
2228
2229/*:VRX Columns_07_Click
2230*/
2231Columns_07_Click:
2232 call _ColumnShow
2233return
2234
2235/*:VRX Columns_08_Click
2236*/
2237Columns_08_Click:
2238 call _ColumnShow
2239return
2240
2241/*:VRX Columns_09_Click
2242*/
2243Columns_09_Click:
2244 call _ColumnShow
2245return
2246
2247/*:VRX Columns_10_Click
2248*/
2249Columns_10_Click:
2250 call _ColumnShow
2251return
2252
2253/*:VRX Columns_11_Click
2254*/
2255Columns_11_Click:
2256 call _ColumnShow
2257return
2258
2259/*:VRX Columns_12_Click
2260*/
2261Columns_12_Click:
2262 call _ColumnShow
2263return
2264
2265/*:VRX Columns_13_Click
2266*/
2267Columns_13_Click:
2268 call _ColumnShow
2269return
2270
2271/*:VRX Columns_14_Click
2272*/
2273Columns_14_Click:
2274 call _ColumnShow
2275return
2276
2277/*:VRX Columns_15_Click
2278*/
2279Columns_15_Click:
2280 call _ColumnShow
2281return
2282
2283/*:VRX Columns_16_Click
2284*/
2285Columns_16_Click:
2286 call _ColumnShow
2287return
2288
2289/*:VRX Columns_17_Click
2290*/
2291Columns_17_Click:
2292 call _ColumnShow
2293return
2294
2295/*:VRX Contextmenu_GroupAdd_Click
2296*/
2297Contextmenu_GroupAdd_Click:
2298 window = VRLoadSecondary( "AddGroup", "W" )
2299return
2300
2301/*:VRX Contextmenu_GroupDel_Click
2302*/
2303Contextmenu_GroupDel_Click:
2304 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2305 if SelGRH.0 = 0 then return
2306 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2307say 'Selected Group Nr = ' SelGNr
2308 Msg.Title = NLVGetMessage(75)
2309 Msg.Type = "Q"
2310 Msg.Text = NLVGetMessage(76,Groupname.SelGNr,NTGroupname.SelGNr,GGID.SelGNr)
2311 ok = _MsgYesNo()
2312 if ok = 1 then do
2313 if RID.SelGNr <> "" then do
2314 say samba.!netexe' rpc group delete "'NTGroupname.SelGNr'" 'UserCred
2315 address cmd samba.!netexe' rpc group delete "'NTGroupname.SelGNr'" 'UserCred' 2>'samba.!error' 1>'samba.!msg
2316 if RC <> 0 then do
2317 call _SambaShowError
2318 return
2319 end
2320 else call _SambaShowMsg
2321 end
2322 do I = 1 to Username.0
2323 if GID.I = GGID.SelGNr then do
2324 GID.I = UID.I
2325 ok = VRMethod("CN_users","SetFieldData", RH.I, GIDFH, GID.I)
2326 end
2327 end
2328 ok = SysStemDelete("groupname.", SelGNr)
2329 ok = SysStemDelete("gpasswd.", SelGNr)
2330 ok = SysStemDelete("ggid.", SelGNr)
2331 ok = SysStemDelete("gusers.", SelGNr)
2332 ok = SysStemDelete("NTGroupname.",SelGNr)
2333 ok = SysStemDelete("RID.", SelGNr)
2334 ok = SysStemDelete("Gstatus.", SelGNr)
2335 ok = VRMethod("CN_Groups", "RemoveRecord", SelGRH.1)
2336 call PB_Save_Click
2337 call PB_Refresh_Click
2338 end
2339return
2340
2341/*:VRX Contextmenu_GroupDetailView_Click
2342*/
2343Contextmenu_GroupDetailView_Click:
2344 ok = VRSet("CN_Groups", "View", "Detail")
2345return
2346
2347/*:VRX Contextmenu_GroupMap_Click
2348*/
2349Contextmenu_GroupMap_Click:
2350 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2351 if SelGRH.0 = 0 then return
2352 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2353say 'Selected Group Nr = ' SelGNr
2354 if RID.SelGnr <> "" then do
2355 Msg.Type = "E"
2356 Msg.Title = NLVGetMessage(91)
2357 Msg.Text = NLVGetMessage(114,Groupname.SelGNr)
2358 call _showMsg
2359 return
2360 end
2361 window = VRLoadSecondary( "MapGroup", "W" )
2362return
2363
2364/*:VRX Contextmenu_GroupMembers_Click
2365*/
2366Contextmenu_GroupMembers_Click:
2367 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2368 if SelGRH.0 = 0 then return
2369 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2370say 'Selected Group Nr = ' SelGNr
2371 CurNTGroupName = NTGroupname.SelGNr
2372 window = VRLoadSecondary( "Group_Members", "W" )
2373return
2374
2375/*:VRX Contextmenu_GroupRebuildScript_Click
2376*/
2377Contextmenu_GroupRebuildScript_Click:
2378 RebuildScript = VRFileDialog( VRWindow(), NLVGetMessage( 99 ), "Save", samba.!bin"\RebuildGroups.CMD", , , )
2379 if RebuildScript = "" then return
2380 ok = SysFileDelete(RebuildScript)
2381 call lineout RebuildScript,'@echo off'
2382 call lineout RebuildScript, 'rem Created by SmbUsers 'VRGet("Main","Hinttext")
2383 do I = 1 to groupname.0
2384 if RID.I <> "" then do
2385 select
2386 when left(translate(NTGroupType.I),4) = "WELL" then Gtype = 'builtin'
2387 when left(translate(NTGroupType.I),4) = "LOCA" then Gtype = 'local'
2388 otherwise Gtype = 'domain'
2389 end
2390 call lineout RebuildScript, 'net groupmap add rid='RID.I' ntgroup="'NTGroupName.I'" unixgroup="'Groupname.I'" type='GType' comment="'NTComment.I'"'
2391 end
2392 end
2393 call lineout RebuildScript, 'echo Done.'
2394 Msg.Title = NLVGetMessage( 98 )
2395 Msg.Type = "I"
2396 Msg.Text = NLVGetMessage( 108, RebuildScript )
2397 call _ShowMsg
2398return
2399
2400/*:VRX Contextmenu_GroupSymbolView_Click
2401*/
2402Contextmenu_GroupSymbolView_Click:
2403 ok = VRSet("CN_Groups", "View", "Icon")
2404return
2405
2406/*:VRX Contextmenu_GroupUnmap_Click
2407*/
2408Contextmenu_GroupUnmap_Click:
2409 ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." )
2410 if SelGRH.0 = 0 then return
2411 SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH)
2412say 'Selected Group Nr = ' SelGNr
2413 if RID.SelGnr = "" then do
2414 Msg.Type = "E"
2415 Msg.Title = NLVGetMessage( 95 )
2416 Msg.Text = NLVGetMessage(96, Groupname.SelGNr )
2417 call _showMsg
2418 return
2419 end
2420 Msg.Type = "E"
2421 Msg.Title = NLVGetMessage( 95 )
2422 Msg.Text = NLVGetMessage( 97, NTGroupname.SelGNr, GroupName.SelGNr )
2423 ok = _MsgYesNo()
2424 if ok = 1 then do
2425 blGusers = translate(Gusers.SelGnr,' ',',')
2426 do I = 1 to words(blGusers)
2427 address cmd samba.!netexe' rpc group delmem "'NTGroupname.SelGNr'" 'word(BlGusers,I)' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2428 if RC <> 0 then call _SambaShowError
2429 else call _SambaShowMsg
2430 say samba.!netexe' RC = 'RC
2431 end
2432 say samba.!netexe' groupmap delete ntgroup="'NTGroupname.SelGNr'" 'debuglevel
2433 address cmd samba.!netexe' groupmap delete ntgroup="'NTGroupname.SelGNr'" 'debuglevel' 2>'samba.!error' 1>'samba.!msg
2434 if RC <> 0 then call _SambaShowError
2435 else call _SambaShowMsg
2436 call PB_Refresh_Click
2437 end
2438return
2439
2440/*:VRX Contextmenu_GroupWellKnown_Click
2441*/
2442Contextmenu_GroupWellKnown_Click:
2443 if Groupname.0 <> 0 then do
2444 Msg.Title = NLVGetMessage( 92 )
2445 Msg.Text = NLVGetMessage( 93 )
2446 Msg.Type = "W"
2447 call _ShowMsg
2448 return
2449 end
2450 call _kLIBCGroupADD "admins", 512
2451 call _kLIBCGroupADD "users", 513
2452 call _kLIBCGroupADD "guests", 514
2453 call _kLIBCGroupADD "machines", 515
2454 call _kLIBCGroupADD "dc", 516
2455 call _kLIBCGroupADD "certadmin", 517
2456 call _kLIBCGroupADD "schemeadmin", 518
2457 call _kLIBCGroupADD "entadmin", 519
2458 call _kLIBCGroupADD "poladmin", 520
2459 call PB_Save_Click
2460
2461 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
2462 if RC <> 0 then call _SambaShowError
2463
2464 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
2465 if RC <> 0 then call _SambaShowError
2466
2467 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
2468 if RC <> 0 then call _SambaShowError
2469
2470 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
2471 if RC <> 0 then call _SambaShowError
2472
2473 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
2474 if RC <> 0 then call _SambaShowError
2475
2476 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
2477 if RC <> 0 then call _SambaShowError
2478
2479 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
2480 if RC <> 0 then call _SambaShowError
2481
2482 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
2483 if RC <> 0 then call _SambaShowError
2484
2485 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
2486 if RC <> 0 then call _SambaShowError
2487
2488 Msg.Title = NLVGetMessage( 92 )
2489 Msg.Type = "I"
2490 Msg.Text = NLVGetMessage( 94 )
2491 call _ShowMsg
2492 call PB_Refresh_Click
2493return
2494
2495/*:VRX Contextmenu_UserAdd_Click
2496*/
2497Contextmenu_UserAdd_Click:
2498 IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() started'
2499 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2500 if SelRH.0 = 0 then do
2501 IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() done, aborted'
2502 return
2503 end
2504 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2505/* IF options.!debug == 1 THEN say ' Flags.SelNr = "'flags.SelNr'"' */
2506 if flags.SelNr = "" then IsUnixUser = 1
2507 else IsUnixUser = 0
2508 IF options.!debug == 1 THEN say ' Selected User Nr = 'SelNr
2509 IF options.!debug == 1 THEN say ' Is kLIBC User only? 'IsUnixUser
2510 window = VRLoadSecondary( "AddUser", "W" )
2511 IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() done'
2512return
2513
2514/*:VRX Contextmenu_UserDel_Click
2515*/
2516Contextmenu_UserDel_Click:
2517 IF options.!debug == 1 THEN say 'Contextmenu_UserDel_Click() started'
2518 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2519 if SelRH.0 = 0 then return
2520 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2521 IF options.!debug == 1 THEN say ' Selected User Nr = 'SelNr
2522 Msg.Title = NLVGetMessage(50)
2523 Msg.Text = NLVGetMessage(51, '"'Username.SelNr'" (UID: 'UID.SelNr')')
2524 ok = _MsgYesNo()
2525 if ok = 1 then do
2526 if flags.SelNr <> "" then do
2527 say ' 'samba.!netexe' rpc user delete "'Username.SelNr'" 'UserCred' 'Debuglevel' 2>'samba.!error' 1>'samba.!msg
2528 address cmd samba.!netexe' rpc user delete "'Username.SelNr'" 'UserCred' 'Debuglevel' 2>'samba.!error' 1>'samba.!msg
2529 if rc <> 0 then call _SambaShowError; else call _SambaShowMsg
2530 if swatauth then do
2531 say ' 'samba.!htpasswdexe' -D "'swatusers'" 'Username.SelNr
2532 address cmd samba.!htpasswdexe' -D "'swatusers'" 'Username.SelNr' 2>'samba.!error' 1>'samba.!msg
2533 if rc <> 0 then call _SambaShowError
2534 else call _SambaShowMsg
2535 end
2536 end
2537 else do /* kLIBC user only */
2538 ExUserName = Username.SelNr
2539 ExUID = UID.SelNr
2540 ExGID = GID.SelNr
2541 ok = SysStemDelete("username.",SelNr)
2542 ok = SysStemDelete("password.",SelNr)
2543 ok = SysStemDelete("uid.",SelNr)
2544 ok = SysStemDelete("gid.",SelNr)
2545 ok = SysStemDelete("loginclass.",SelNr)
2546 ok = SysStemDelete("pwchange.",SelNr)
2547 ok = SysStemDelete("deact.",SelNr)
2548 ok = SysStemDelete("gecos.",SelNr)
2549 ok = SysStemDelete("home.",SelNr)
2550 ok = SysStemDelete("shell.",SelNr)
2551 ok = SysStemDelete("status.",SelNr)
2552 ok = SysStemDelete("lmhash.",SelNr)
2553 ok = SysStemDelete("nthash.",SelNr)
2554 ok = SysStemDelete("flags.",SelNr)
2555 ok = SysStemDelete("lct.",SelNr)
2556 do I = 1 to gusers.0
2557 blGUsers = translate(Gusers.I,' ',',')
2558 UPos = wordpos(translate(ExUserName),translate(blGusers))
2559 if Upos > 0 then do
2560 blGUsers = delword(BlGusers,UPos,1)
2561 Gusers.I = translate(blGusers,',',' ')
2562 end
2563 end
2564 call PB_Save_Click
2565 Msg.Title = NLVGetMessage(50)
2566 Msg.Text = NLVGetMessage(53, '"'ExUsername'"' )
2567 Msg.Type = 'I'
2568 call _ShowMsg
2569 end
2570 call PB_Refresh_Click
2571 end
2572 IF options.!debug == 1 THEN say 'Contextmenu_UserDel_Click() done'
2573return
2574
2575/*:VRX Contextmenu_UserDetailView_Click
2576*/
2577Contextmenu_UserDetailView_Click:
2578 ok = VRSet("CN_users", "View", "Detail")
2579return
2580
2581/*:VRX Contextmenu_UserJoinGroup_Click
2582*/
2583Contextmenu_UserJoinGroup_Click:
2584 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2585 if SelRH.0 = 0 then return
2586 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2587 say 'Selected User Nr = ' SelNr
2588 window = VRLoadSecondary( "Join_Group", "W" )
2589return
2590
2591/*:VRX Contextmenu_UserLeaveGroup_Click
2592*/
2593Contextmenu_UserLeaveGroup_Click:
2594 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." )
2595 if SelRH.0 = 0 then return
2596 SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH)
2597 say 'Selected User Nr = ' SelNr
2598 window = VRLoadSecondary( "Leave_Group", "W" )
2599return
2600
2601/*:VRX Contextmenu_UserProperties_Click
2602*/
2603Contextmenu_UserProperties_Click:
2604 window = VRLoadSecondary( "UserProperties", "W" )
2605return
2606
2607/*:VRX Contextmenu_UserSymbolView_Click
2608*/
2609Contextmenu_UserSymbolView_Click:
2610 ok = VRSet("CN_users", "View", "Icon")
2611return
2612
2613/*:VRX DDCB_GID_Change
2614*/
2615DDCB_GID_Change:
2616 ok = VRSet("DT_PrimaryGroupName","Caption","UID")
2617 if VRGet("DDCB_GID","Value") = NextUID then return
2618 do x = 1 to groupname.0
2619 if VRGet("DDCB_GID","Value") = GGID.x then do
2620 ok = VRSet("DT_PrimaryGroupName","Caption",groupname.x' ('NTGroupName.x')')
2621 leave
2622 end
2623 end
2624return
2625
2626/*:VRX DDCB_Policy_Change
2627*/
2628DDCB_Policy_Change:
2629 say samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" 'DebugLevel' 1>'samba.!msg' 2>'samba.!error
2630 address cmd samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" 'DebugLevel' 1>'samba.!msg
2631 PolDesc = linein(samba.!msg)
2632 PolValue = linein(samba.!msg)
2633 ok = stream(Samba.!msg,'c','close')
2634
2635 parse var PolDesc . ':' PolDesc
2636 parse var PolValue . ':' PolValue
2637say strip(PolValue)
2638say strip(PolDesc)
2639 ok = VRset("EF_PolValue","Value",strip(PolValue))
2640 ok = VRSet("GB_Policy","HintText",strip(PolDesc))
2641return
2642
2643/*:VRX EF_Comment_Change
2644*/
2645EF_Comment_Change:
2646 if pos(':',VRGet("EF_GroupName","Value")) > 0 then ok = VRset("EF_Groupname","Value",translate(VRGet("EF_GroupName","Value"),'-',':'))
2647return
2648
2649/*:VRX EF_Description_Change
2650*/
2651EF_Description_Change:
2652 if VRGet("EF_Description","value") <> "" then do
2653 SecondStage = 1
2654 end
2655 else SecondStage = (SecondStage | 0)
2656return
2657
2658/*:VRX EF_GGID_Change
2659*/
2660EF_GGID_Change:
2661 if VRGet("EF_GGID","Value") <> "" then do
2662 if datatype(VRGet("EF_GGID","Value")) <> "NUM" then ok = VRSet("EF_GGID","Value","")
2663 end
2664return
2665
2666/*:VRX EF_Groupname_Change
2667*/
2668EF_Groupname_Change:
2669 if pos(':',VRGet("EF_GroupName","Value")) > 0 then ok = VRset("EF_Groupname","Value",translate(VRGet("EF_GroupName","Value"),'-',':'))
2670return
2671
2672/*:VRX EF_Home_Change
2673*/
2674EF_Home_Change:
2675 if pos('NONEXISTENT', translate(VRGet("EF_Home", "Value"))) > 0 then do
2676 ok = VRset("PB_CreateHome","Enabled",0)
2677 return
2678 end
2679
2680 if \VRFileExists( VRGet("EF_Home", "Value") ) then do
2681 ok = VRSet("EF_Home","ForeColor", "Red")
2682 ok = VRset("PB_CreateHome","Enabled",\VRGet("CB_NoHome","set"))
2683 end
2684 else do
2685 ok = VRSet("EF_Home","ForeColor", "<default>")
2686 ok = VRset("PB_CreateHome","Enabled",0)
2687 end
2688return
2689
2690/*:VRX EF_LoginPassword_KeyPress
2691*/
2692EF_LoginPassword_KeyPress:
2693 obj = VRInfo( "Object" )
2694 keystr = VRGet( obj, "KeyString" )
2695/* say keystr */
2696 select
2697 when keystr = "{Enter}" then call PB_LOGIN_OK_Click
2698 when keystr = "{Newline}" then call PB_LOGIN_OK_Click
2699 when keystr = "{Esc}" then call PB_LOGIN_CANCEL_Click
2700 otherwise nop
2701 end
2702return
2703
2704/*:VRX EF_LoginUser_KeyPress
2705*/
2706EF_LoginUser_KeyPress:
2707 obj = VRInfo( "Object" )
2708 keystr = VRGet( obj, "KeyString" )
2709/* say keystr */
2710 select
2711 when keystr = "{Enter}" then ok = VRMethod( "EF_LoginPassword", "SetFocus" )
2712 when keystr = "{Newline}" then ok = VRMethod( "EF_LoginPassword", "SetFocus" )
2713 when keystr = "{Esc}" then call PB_LOGIN_CANCEL_Click
2714 otherwise nop
2715 end
2716return
2717
2718/*:VRX EF_upPassword_Change
2719*/
2720EF_upPassword_Change:
2721 ok = VRSet("CB_upSWAT_Allowed","Enabled",1)
2722return
2723
2724/*:VRX EF_Username_Change
2725*/
2726EF_Username_Change:
2727 if pos(':',VRGet("EF_Username","Value")) > 0 then ok = VRset("EF_Username","Value",translate(VRGet("EF_Username","Value"),'-',':'))
2728 ok = VRSet("EF_Home","Value", Samba.!homes'\'VRGet("EF_Username","Value"))
2729 call CB_MachineAccount_Click
2730 if VRGet("EF_Username","Value") = "" then do
2731 if IsUnixUser then do
2732 IsUnixuser = 0
2733 drop UnixUserNr
2734 ok = VRSet( "DT_UID", "BackColor", "<default>")
2735 ok = VRSet( "DT_UID", "ForeColor", "<default>")
2736 NextUID = _GetNextUID(VRGet("EF_Username","value"))
2737 IsUnixUser = 0
2738 ok = VRSet("DT_UID","Caption", "UID: "NextUID)
2739 ok = VRSet("DDCB_GID","Value", NextUID)
2740 ok = VRMethod( "DDCB_GID", "Reset")
2741 ok = VRMethod( "DDCB_GID", "AddString", NextUID)
2742 ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.")
2743 ok = VRSet("EF_GECOS","Value","")
2744 ok = VRSet("EF_Home","Value","")
2745 end
2746 end
2747 else do
2748 NextUID = _GetNextUID(VRGet("EF_Username","value"))
2749 ok = VRSet("DT_UID","Caption", "UID: "NextUID)
2750 if NextUID > 65000 then do
2751 ok = VRset("EF_Description","Value",NLVGetMessage(116))
2752 ok = VRset("CB_NoPassword","set", 1)
2753 call CB_NoPassword_Click
2754 ok = VRset("DDCB_GID","value",NextUID)
2755 ok = VRMethod("DDCB_GID","addString", NextUID)
2756 end
2757 else ok = VRset("DDCB_GID","value","513")
2758 end
2759return
2760
2761/*:VRX EF_Username_LostFocus
2762*/
2763EF_Username_LostFocus:
2764 do I = 1 to Username.0
2765 if translate(Username.I) = translate(VRGet("EF_username","value")) then do
2766 if flags.I = "" then do
2767 IsUnixuser = 1
2768 UnixUserNr = I
2769 ok = VRSet( "DT_UID", "BackColor", "DarkGreen")
2770 ok = VRSet( "DT_UID", "ForeColor", "White")
2771 ok = VRSet( "DT_UID", "Caption", "UID: "UID.I)
2772 ok = VRSet( "EF_GECOS","Value", GECOS.I)
2773 ok = VRSet( "DDCB_GID","Value", GID.I)
2774 ok = VRMethod( "DDCB_GID", "Reset")
2775 ok = VRMethod( "DDCB_GID", "AddString", UID.I)
2776 ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.")
2777 ok = VRSet( "EF_Home","Value", _PathStrOS2(Home.I))
2778 end
2779 else do
2780 Msg.Type = "E"
2781 Msg.Text = NLVGetMessage( 105)
2782 call _ShowMsg
2783 ok = VRSet("EF_username","value","")
2784 ok = VRMethod("EF_username","SetFocus")
2785 end
2786 leave
2787 end
2788 end
2789return
2790
2791/*:VRX Fini
2792*/
2793Fini:
2794 window = VRWindow()
2795 call VRSet window, "Visible", 0
2796 drop window
2797return 0
2798
2799/*:VRX GetBootDrive
2800*/
2801GetBootDrive:
2802/* Use SysBootDrive if possible */
2803If Rxfuncadd('SysBootDrive', 'RexxUtil', 'SysBootDrive') Then
2804 Return Left(Value('RUNWORKPLACE',,'OS2ENVIRONMENT'),2)
2805Else
2806 Return SysBootDrive()
2807
2808
2809/*:VRX Group_Members_Close
2810*/
2811Group_Members_Close:
2812 call Group_Members_Fini
2813return
2814
2815/*:VRX Group_Members_Create
2816*/
2817Group_Members_Create:
2818 call Group_Members_Init
2819 ok = VRSet("Group_Members","Caption", NLVGetMessage(89)||' "'CurNTGroupName'"')
2820 CALL NLVSetText 'PB_GroupMembersOK', 'Caption', 2
2821
2822 ok = VRMethod("LB_GroupMembers","Reset")
2823 ok = VRSet("Main", 'Pointer', 'Wait' )
2824 say samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2825 address cmd samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2826 if RC <> 0 then call _SambaShowError
2827 else do
2828 do while lines(samba.!msg) <> 0
2829 groupmember = linein(samba.!msg)
2830 say groupmember
2831 ok = VRMethod("LB_GroupMembers","AddString", groupmember)
2832 end
2833 ok = stream(Samba.!msg,"c","close")
2834 end
2835 ok = VRSet("Main", 'Pointer', '<default>' )
2836return
2837
2838/*:VRX Group_Members_Fini
2839*/
2840Group_Members_Fini:
2841 window = VRInfo( "Window" )
2842 call VRDestroy window
2843 drop window
2844return
2845/*:VRX Group_Members_Init
2846*/
2847Group_Members_Init:
2848 window = VRInfo( "Object" )
2849 if( \VRIsChildOf( window, "Notebook" ) ) then do
2850 call VRMethod window, "CenterWindow"
2851 call VRSet window, "Visible", 1
2852 call VRMethod window, "Activate"
2853 end
2854 drop window
2855return
2856
2857/*:VRX Halt
2858*/
2859Halt:
2860 signal _VREHalt
2861return
2862
2863/*:VRX Init
2864*/
2865Init:
2866window = VRWindow()
2867call VRMethod window, "CenterWindow"
2868call VRSet window, "Visible", 0
2869call VRMethod window, "Activate"
2870drop window
2871return
2872
2873/*:VRX IPB_AccountFlags_Click
2874*/
2875IPB_AccountFlags_Click:
2876 ok = VRSet("IPB_AccountFlags","PicturePath", "#16;#16")
2877 ok = VRSet("IPB_Profile","PicturePath", "#27;#27")
2878 ok = VRSet("IPB_Memberships","PicturePath", "#28;#28")
2879
2880 ok = VRSet("GB_Flags","Left", 140)
2881 ok = VRSet("GB_Flags","Top", 140)
2882 ok = VRSet("GB_Flags","Width", VRGet("GB_upOuter","Width") - 280)
2883 ok = VRSet("GB_Flags","Height",VRGet("GB_upOuter","Height") - 280)
2884 ok = VRSet("GB_GroupMemberShips","Visible", 0)
2885 ok = VRset("GB_Profile", "Visible", 0)
2886 ok = VRSet("GB_Flags","Visible", 1)
2887return
2888
2889/*:VRX IPB_GroupAdd_Click
2890*/
2891IPB_GroupAdd_Click:
2892 call Contextmenu_GroupAdd_Click
2893return
2894
2895/*:VRX IPB_GroupDel_Click
2896*/
2897IPB_GroupDel_Click:
2898 call Contextmenu_GroupDel_Click
2899return
2900
2901/*:VRX IPB_GroupMap_Click
2902*/
2903IPB_GroupMap_Click:
2904 call Contextmenu_GroupMap_Click
2905return
2906
2907/*:VRX IPB_GroupScript_Click
2908*/
2909IPB_GroupScript_Click:
2910 call Contextmenu_GroupRebuildScript_Click
2911return
2912
2913/*:VRX IPB_GroupUnMap_Click
2914*/
2915IPB_GroupUnMap_Click:
2916 call Contextmenu_GroupUnMap_Click
2917return
2918
2919/*:VRX IPB_GroupWellknown_Click
2920*/
2921IPB_GroupWellknown_Click:
2922 call Contextmenu_GroupWellKnown_Click
2923return
2924
2925/*:VRX IPB_Memberships_Click
2926*/
2927IPB_Memberships_Click:
2928 ok = VRSet("IPB_AccountFlags","PicturePath", "#26;#26")
2929 ok = VRSet("IPB_Profile","PicturePath", "#27;#27")
2930 ok = VRSet("IPB_Memberships","PicturePath", "#18;#18")
2931
2932 ok = VRSet("GB_GroupMemberShips","Left", 140)
2933 ok = VRSet("GB_GroupMemberShips","Top", 140)
2934 ok = VRSet("GB_GroupMemberShips","Width", VRGet("GB_upOuter","Width") - 280)
2935 ok = VRSet("GB_GroupMemberShips","Height",VRGet("GB_upOuter","Height") - 280)
2936 ok = VRSet("GB_GroupMemberShips","Visible", 1)
2937 ok = VRset("GB_Flags", "Visible", 0)
2938 ok = VRset("GB_Profile", "Visible", 0)
2939 ok = VRMethod("LB_upGroups","Reset")
2940 ok = VRSet("Main", 'Pointer', 'Wait' )
2941 address cmd samba.!netexe' rpc user info 'Username.CurUserNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
2942 if RC <> 0 then call _SambaShowError
2943 else do
2944 do while lines(samba.!msg) <> 0
2945 ok = VRMethod("LB_upGroups","AddString", linein(samba.!msg))
2946 end
2947 ok = stream(Samba.!msg,"c","close")
2948 end
2949 ok = VRSet("Main", 'Pointer', '<default>' )
2950return
2951
2952/*:VRX IPB_Paper_Click
2953*/
2954IPB_Paper_Click:
2955 if VRInfo("Left") > VRInfo("Top") then call Activate min(CurrentPageNr+1,Pages)
2956 if VRInfo("Left") <= VRInfo("Top") then call Activate max(CurrentPageNr-1,1)
2957return
2958
2959/*:VRX IPB_Profile_Click
2960*/
2961IPB_Profile_Click:
2962 ok = VRSet("IPB_AccountFlags","PicturePath", "#26;#26")
2963 ok = VRSet("IPB_Profile","PicturePath", "#17;#17")
2964 ok = VRSet("IPB_Memberships","PicturePath", "#28;#28")
2965
2966 ok = VRSet("GB_Profile","Left", 140)
2967 ok = VRSet("GB_Profile","Top", 140)
2968 ok = VRSet("GB_Profile","Width", VRGet("GB_upOuter","Width") - 280)
2969 ok = VRSet("GB_Profile","Height",VRGet("GB_upOuter","Height") - 280)
2970 ok = VRSet("CN_UserProperties","Width",VRGet("GB_Profile","Width")-240)
2971 ok = VRset("GB_Flags", "Visible", 0)
2972 ok = VRSet("GB_GroupMemberShips","Visible", 0)
2973 ok = VRSet("GB_Profile","Visible", 1)
2974return
2975
2976/*:VRX IPB_UserAdd_Click
2977*/
2978IPB_UserAdd_Click:
2979 call Contextmenu_UserAdd_Click
2980return
2981
2982/*:VRX IPB_UserDel_Click
2983*/
2984IPB_UserDel_Click:
2985 call Contextmenu_UserDel_Click
2986return
2987
2988/*:VRX IPB_UserJoinGroup_Click
2989*/
2990IPB_UserJoinGroup_Click:
2991 call Contextmenu_UserJoinGroup_Click
2992return
2993
2994/*:VRX IPB_UserLeaveGroup_Click
2995*/
2996IPB_UserLeaveGroup_Click:
2997 call Contextmenu_UserLeaveGroup_Click
2998return
2999
3000/*:VRX Join_Group_Close
3001*/
3002Join_Group_Close:
3003 call Join_Group_Fini
3004return
3005
3006/*:VRX Join_Group_Create
3007*/
3008Join_Group_Create:
3009 call Join_Group_Init
3010 CALL NLVSetText 'Join_Group', 'Caption', 80
3011 CALL NLVSetText 'DT_JoinGroup', 'Caption', 81
3012 CALL NLVSetText 'PB_JoinOK', 'Caption', 2
3013 CALL NLVSetText 'PB_JoinCancel', 'Caption', 3
3014
3015 call VRSet "LB_Groups", "Painting", 0
3016 ok = VRMethod("LB_Groups","AddStringList", "NTGroupName.")
3017 address cmd samba.!netexe' rpc user info 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3018 if RC <> 0 then call _SambaShowError
3019 else do
3020 do while lines(samba.!msg) <> 0
3021 AlreadyMember = linein(samba.!msg)
3022 ok = VRMethod( "LB_Groups", "DeleteString", AlreadyMember )
3023 if settings.!FixErrors then do
3024 do I = 1 to NTGroupName.0
3025 if AlreadyMember = NTGroupName.I then do
3026 if pos(Username.SelNr,GUsers.I) = 0 then do
3027 Gusers.I = Username.SelNr','Gusers.I
3028 ok = VRMethod("CN_Groups", "SetFieldData", GRH.I, GUsersFH, Gusers.I)
3029 call _GroupWrite
3030 end
3031 end
3032 end
3033 end
3034 end
3035 ok = stream(Samba.!msg,"c","close")
3036 end
3037 call VRSet "LB_Groups", "Painting", 1
3038return
3039
3040/*:VRX Join_Group_Fini
3041*/
3042Join_Group_Fini:
3043 window = VRInfo( "Window" )
3044 call VRDestroy window
3045 drop window
3046return
3047/*:VRX Join_Group_Init
3048*/
3049Join_Group_Init:
3050 window = VRInfo( "Object" )
3051 if( \VRIsChildOf( window, "Notebook" ) ) then do
3052 call VRMethod window, "CenterWindow"
3053 call VRSet window, "Visible", 1
3054 call VRMethod window, "Activate"
3055 end
3056 drop window
3057return
3058
3059/*:VRX Leave_Group_Close
3060*/
3061Leave_Group_Close:
3062 call Leave_Group_Fini
3063return
3064
3065/*:VRX Leave_Group_Create
3066*/
3067Leave_Group_Create:
3068 call Leave_Group_Init
3069 CALL NLVSetText 'Leave_Group', 'Caption', 85
3070 CALL NLVSetText 'DT_LeaveGroup', 'Caption', 86
3071 CALL NLVSetText 'PB_LeaveOK', 'Caption', 2
3072 CALL NLVSetText 'PB_LeaveCancel', 'Caption', 3
3073 address cmd samba.!netexe' rpc user info 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3074 if RC <> 0 then call _SambaShowError
3075 else do
3076 call VRSet "LB_LeaveGroups", "Painting", 0
3077 do while lines(samba.!msg) <> 0
3078 ok = VRMethod("LB_LeaveGroups","AddString", linein(samba.!msg))
3079 end
3080 ok = stream(Samba.!msg,"c","close")
3081 call VRSet "LB_LeaveGroups", "Painting", 1
3082 end
3083return
3084
3085/*:VRX Leave_Group_Fini
3086*/
3087Leave_Group_Fini:
3088 window = VRInfo( "Window" )
3089 call VRDestroy window
3090 drop window
3091return
3092/*:VRX Leave_Group_Init
3093*/
3094Leave_Group_Init:
3095 window = VRInfo( "Object" )
3096 if( \VRIsChildOf( window, "Notebook" ) ) then do
3097 call VRMethod window, "CenterWindow"
3098 call VRSet window, "Visible", 1
3099 call VRMethod window, "Activate"
3100 end
3101 drop window
3102return
3103
3104/*:VRX Main_Close
3105*/
3106Main_Close:
3107 call Quit
3108return
3109
3110/*:VRX Main_Create
3111*/
3112Main_Create:
3113 options.!debug = 0
3114 /* Default title */
3115 Msg.Title = VRGet("Main", "Caption")
3116
3117 call _LoadOtherFuncs
3118 call _IniRead
3119 call _NLVSetup
3120
3121 /* Nationalized title */
3122 Msg.Title = VRGet("Main", "Caption")
3123 call _InitTempdir
3124 call _ParseCommandLine
3125
3126 StartSamba = \_SambaRunning()
3127
3128 call _SambaInit
3129say "hier!"
3130 if ErrorState then call _OnErrorDisable
3131say "hier jetzt!"
3132 if StartSamba then do
3133 address cmd samba.!smbcmd' start'
3134 end
3135say "hier2!"
3136 if \_SambaRunning() then do
3137 Msg.Text = NLVGetMessage(107)
3138 Msg.Type = "E"
3139 call _ShowMsg
3140 call Quit
3141 return
3142 end
3143 else if StartSamba then do
3144 Msg.Text = NLVGetMessage(109)
3145 Msg.Type = "I"
3146 call _ShowMsg
3147 end
3148
3149 call _SambaGetProperties
3150
3151 call _FindHtpasswd
3152
3153 call _ContainersInit
3154
3155 call _MasterPasswdRead
3156 call _Login
3157
3158 call _SmbpasswdRead
3159 call _SmbUserMapRead
3160 call _GroupRead
3161 call _SmbGroupsRead
3162
3163 call _GUIInit
3164
3165 call _ContainerPopulate
3166 call _ContGroupsPopulate
3167 call _PoliciesPopulate
3168
3169 ok = VRMethod("PB_Exit","SetFocus")
3170 call TAB_1_Click
3171 call Main_Resize
3172return
3173/*:VRX Main_Resize
3174*/
3175Main_Resize:
3176 IF options.!debug == 1 THEN say 'Main_Resize() started.'
3177 MainWin = "Main"
3178 ok = VRSet(MainWin,"Painting", 0)
3179/* ok = VRset(MainWin,"Visible", 0) */
3180 ok = VRSet(MainWin,"Width",max(VRget(MainWin,"Width"),Pages*TabWidth+300))
3181 ok = VRset("GB_Main","width",VRget(MainWin,"Width")-150)
3182 ok = VRset("GB_Main","Height",VRget(MainWin,"Height")-1175-240)
3183 ok = VRset("GB_Main2","width",VRget("GB_Main","Width")-260)
3184 ok = VRset("GB_Main2","Height",VRget("GB_Main","Height")-275)
3185 ok = VRset("GB_VerticalLine","Left",VRget("GB_Main2","Width")-60)
3186 ok = VRset("GB_VerticalLine","Height",VRget("GB_Main2","Height")-410)
3187 ok = VRset("IPB_Paper","Left",VRget("GB_Main2","width")-420)
3188 ok = VRset("GB_HorLineTop","Width",VRget("GB_Main2","width")-440)
3189 ok = VRset("GB_HorLineTop","Width",VRget("GB_Main2","width")-440)
3190 ok = VRset("GB_LineSubtitle","Width",VRget("GB_Main2","width")-480)
3191 do I = 1 to Pages
3192 /* say 'Page_'I'='max(PageHeight,VRget("GB_Main2","Height")-600) */
3193 ok = VRSet("Page_"I,"Height", max(PageHeight,VRget("GB_Main2","Height")-600))
3194 ok = VRSet("Page_"I,"Width", max(PageWidth,VRget("GB_Main2","Width")-450))
3195 end
3196
3197 /* Main window buttons */
3198 ok = VRSEt("PB_RPC", "top",VRGet("GB_Main","Height")+305)
3199 ok = VRSEt("PB_Help", "top",VRGet("GB_Main","Height")+305)
3200 ok = VRSEt("PB_Save", "top",VRGet("GB_Main","Height")+305)
3201 ok = VRSEt("PB_Refresh","top",VRGet("GB_Main","Height")+305)
3202 ok = VRSEt("PB_Exit", "top",VRGet("GB_Main","Height")+305)
3203 ok = VRSEt("PB_About", "top",VRGet("GB_Main","Height")+305)
3204
3205 /* Users page */
3206 ok = VRset("CN_Users","Top", 120)
3207 ok = VRset("CN_Users","Left", 20)
3208 ok = VRset("CN_Users","Width", VRGet("Page_1","Width")-600)
3209 ok = VRset("CN_Users","Height", VRGet("Page_1","Height")-360)
3210 ok = VRset("CB_SmbOnly","Left", 20)
3211 ok = VRset("CB_SmbOnly","Top", VRGet("CN_Users","Height")+120 )
3212 ok = VRSet("IPB_UserAdd", "Top", 120 )
3213 ok = VRSet("IPB_UserAdd", "Left", VRGet("CN_Users","Width") + 80 )
3214 ok = VRSet("IPB_UserDel", "Top", 720 )
3215 ok = VRSet("IPB_UserDel", "Left", VRGet("CN_Users","Width") + 80 )
3216 ok = VRSet("IPB_UserJoinGroup", "Top", 1320 )
3217 ok = VRSet("IPB_UserJoinGroup", "Left", VRGet("CN_Users","Width") + 80 )
3218 ok = VRSet("IPB_UserLeaveGroup", "Top", 1920 )
3219 ok = VRSet("IPB_UserLeaveGroup", "Left", VRGet("CN_Users","Width") + 80 )
3220
3221
3222 /* Groups page */
3223 ok = VRset("CN_Groups","Top", 120)
3224 ok = VRset("CN_Groups","Left", 20)
3225 ok = VRset("CN_Groups","Width", VRGet("Page_2","Width")-600)
3226 ok = VRset("CN_Groups","Height", VRGet("Page_2","Height")-360)
3227 ok = VRSet("IPB_GroupAdd", "Top", 120 )
3228 ok = VRSet("IPB_GroupAdd", "Left", VRGet("CN_Users","Width") + 80 )
3229 ok = VRSet("IPB_GroupMap", "Top", 720 )
3230 ok = VRSet("IPB_GroupMap", "Left", VRGet("CN_Users","Width") + 80 )
3231 ok = VRSet("IPB_GroupDel", "Top", 1320 )
3232 ok = VRSet("IPB_GroupDel", "Left", VRGet("CN_Users","Width") + 80 )
3233 ok = VRSet("IPB_GroupUnMap", "Top", 1920 )
3234 ok = VRSet("IPB_GroupUnMap", "Left", VRGet("CN_Users","Width") + 80 )
3235 ok = VRSet("IPB_GroupScript", "Top", 2520 )
3236 ok = VRSet("IPB_GroupScript", "Left", VRGet("CN_Users","Width") + 80 )
3237 ok = VRSet("IPB_GroupWellknown", "Top", 3120 )
3238 ok = VRSet("IPB_GroupWellknown", "Left", VRGet("CN_Users","Width") + 80 )
3239
3240 ok = VRset("CB_SmbGroupsOnly","Left", 20)
3241 ok = VRset("CB_SmbGroupsOnly","Top", VRGet("CN_Groups","Height")+120 )
3242
3243 ButtonDist= 1120
3244 ButtonNr = 6
3245 ButtonPos = format(max((VRget(MainWin,"Width")-ButtonDist*ButtonNr)/2,0),,0)
3246 ok = VRSEt("PB_RPC", "left",ButtonPos+ButtonDist*(ButtonNr-6))
3247 ok = VRSEt("PB_Save", "left",ButtonPos+ButtonDist*(ButtonNr-5))
3248 ok = VRSEt("PB_Refresh","left",ButtonPos+ButtonDist*(ButtonNr-4))
3249 ok = VRSEt("PB_Help", "left",ButtonPos+ButtonDist*(ButtonNr-3))
3250 ok = VRSEt("PB_About", "left",ButtonPos+ButtonDist*(ButtonNr-2))
3251 ok = VRSEt("PB_Exit", "left",ButtonPos+ButtonDist*(ButtonNr-1))
3252
3253 ok = VRSEt("PB_RPC", "width",ButtonDist-80)
3254 ok = VRSEt("PB_Save", "width",ButtonDist-80)
3255 ok = VRSEt("PB_Refresh","width",ButtonDist-80)
3256 ok = VRSEt("PB_Help", "width",ButtonDist-80)
3257 ok = VRSEt("PB_About", "width",ButtonDist-80)
3258 ok = VRSEt("PB_Exit", "width",ButtonDist-80)
3259
3260 /* check and empty event queue, trash spurious resize events */
3261 EventString = ''
3262 TrashedResize = 0
3263 do until EventString = 'nop'
3264 EventString = VREvent('N')
3265 if EventString <> 'nop' then do
3266 if EventString = 'CALL 'MainWin'_Resize' then TrashedResize = 1
3267 else interpret eventString
3268 end
3269 end
3270 if TrashedResize then CALL Main_Resize
3271 ok = VRSet(MainWin, "Painting", 1)
3272
3273 /* ok = VRset(MainWin,"Visible", 1) */
3274 IF options.!debug == 1 THEN say 'Main_Resize() done.'
3275return
3276
3277/*:VRX MapGroup_Close
3278*/
3279MapGroup_Close:
3280 call MapGroup_Fini
3281return
3282
3283/*:VRX MapGroup_Create
3284*/
3285MapGroup_Create:
3286 call MapGroup_Init
3287 CALL NLVSetText 'MapGroup', 'Caption', 60
3288 CALL NLVSetText 'PB_GroupMapOK', 'Caption', 2
3289 CALL NLVSetText 'PB_GroupMapCancel', 'Caption', 3
3290
3291 CALL NLVSetText 'DT_NTGroupname', 'Caption', 61
3292 CALL NLVSetText 'DT_NTGroupComment', 'Caption', 52
3293 CALL NLVSetText 'DT_NTRID', 'Caption', 62
3294 CALL NLVSetText 'DT_NTGroupType', 'Caption', 63
3295 CALL NLVSetText 'RB_NTGroupType_domain','Caption', 64
3296 CALL NLVSetText 'RB_NTGroupType_builtin','Caption', 65
3297 CALL NLVSetText 'RB_NTGroupType_local','Caption', 66
3298
3299 ok = VRSet("EF_NTGroupName","Value", GroupName.SelGNr)
3300 ok = VRSet("EF_NTRID","Value", GGID.SelGNr)
3301 NTGroupType = 'domain'
3302return
3303
3304/*:VRX MapGroup_Fini
3305*/
3306MapGroup_Fini:
3307 window = VRInfo( "Window" )
3308 call VRDestroy window
3309 drop window
3310return
3311/*:VRX MapGroup_Init
3312*/
3313MapGroup_Init:
3314 window = VRInfo( "Object" )
3315 if( \VRIsChildOf( window, "Notebook" ) ) then do
3316 call VRMethod window, "CenterWindow"
3317 call VRSet window, "Visible", 1
3318 call VRMethod window, "Activate"
3319 end
3320 drop window
3321return
3322
3323/*:VRX Page1_Create
3324*/
3325Page1_Create:
3326
3327Return
3328
3329/*:VRX Page1_Init
3330*/
3331Page1_Init:
3332 call _ContainerInit
3333return
3334
3335/*:VRX Page2_Create
3336*/
3337Page2_create:
3338
3339Return
3340/*:VRX Page2_init
3341*/
3342Page2_init:
3343
3344return
3345
3346/*:VRX Page3_Create
3347*/
3348Page3_create:
3349
3350Return
3351/*:VRX Page3_Init
3352*/
3353Page3_Init:
3354
3355return
3356
3357/*:VRX Page4_Create
3358*/
3359Page4_Create:
3360
3361Return
3362/*:VRX Page4_init
3363*/
3364Page4_init:
3365
3366return
3367
3368/*:VRX Page5_Create
3369*/
3370Page5_Create:
3371
3372return
3373
3374/*:VRX Page5_Init
3375*/
3376Page5_Init:
3377
3378return
3379
3380/*:VRX Paper_Init
3381*/
3382Paper_Init:
3383 ok = VRSet("IPB_Paper","Width" ,VRMethod( "Screen", "PixelsToTwips", 32 ))
3384 ok = VRSet("IPB_Paper","Height",VRMethod( "Screen", "PixelsToTwips", 32 ))
3385 ok = VRset("IPB_Paper","Left",VRget("GB_Main2","width")-420)
3386return
3387
3388/*:VRX PB_About_Click
3389*/
3390PB_About_Click:
3391 window = VRLoadSecondary( "About", "W" )
3392return
3393
3394/*:VRX PB_AboutOK_Click
3395*/
3396PB_AboutOK_Click:
3397 call About_Close
3398return
3399
3400/*:VRX PB_AddUserCancel_Click
3401*/
3402PB_AddUserCancel_Click:
3403 call AddUser_Close
3404return
3405
3406/*:VRX PB_AddUserOK_Click
3407*/
3408PB_AddUserOK_Click:
3409 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click started.'
3410 if VRGet("EF_username","Value") ="" then do
3411 Msg.type = "E"
3412 Msg.Text = NLVGetMessage( 101 )
3413 call _ShowMsg
3414 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3415 return
3416 end
3417 if VRGet("EF_password","Value") ="" & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do
3418 Msg.type = "E"
3419 Msg.Text = NLVGetMessage( 102 )
3420 call _ShowMsg
3421 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3422 return
3423 end
3424 if VRGet("EF_password_repeat","Value") ="" & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do
3425 Msg.type = "E"
3426 Msg.Text = NLVGetMessage( 103 )
3427 call _ShowMsg
3428 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3429 return
3430 end
3431
3432 if VRGet("EF_password","Value") <> VRGet("EF_password_repeat","Value") then do
3433 Msg.type = "E"
3434 Msg.Text = NLVGetMessage( 104 )
3435 call _ShowMsg
3436 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3437 return
3438 end
3439
3440 if length(VRGet("EF_password","Value")) < MinPWLength & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do
3441 Msg.type = "E"
3442 Msg.Text = NLVGetMessage( 117 )
3443 call _ShowMsg
3444 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3445 return
3446 end
3447
3448 if (substr(VRGet("DT_UID","Caption"),6) = VRGet("DDCB_GID","Value")) & (substr(VRGet("DT_UID","Caption"),6) < 65000) then do
3449 Msg.Type = "W"
3450 Msg.Text = NLVGetMessage(115)
3451 ok = _MsgYesNo()
3452 if ok = 2 then do
3453 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.'
3454 return
3455 end
3456 end
3457
3458 if IsUnixUser then nx = UnixUserNr
3459 else do
3460 nx = Username.0 + 1
3461 Username.0 = nx
3462 end
3463 Username.nx = VRGet("EF_Username","Value")
3464 UID.nx = substr(VRGet("DT_UID","Caption"),6)
3465 GID.nx = VRGet("DDCB_GID","Value")
3466
3467 if settings.!WriteMasterPwd = 1 then do
3468 call rxFuncAdd "Crypt", "RxCrypt", "RxCrypt"
3469 itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
3470 salt = ""
3471 do i = 1 to 8
3472 salt = salt || substr( itoa64, random( 0, 63 ) + 1, 1 )
3473 end
3474 password.nx = Crypt(VRGet("EF_password","Value"), salt )
3475 end
3476 else password.nx = "*"
3477 loginclass.NX = '' /* dummy value */
3478 pwchange.NX = '0' /* dummy value */
3479 deact.NX = '0' /* dummy value */
3480 gecos.NX = VRGet("EF_GECOS","Value") /* Full name */
3481 home.NX = _PathStrkLIBC(VRGet("EF_Home","Value"))
3482 shell.NX = '/usr/sbin/nologin' /* dummy value */
3483 lmhash.NX = ""
3484 nthash.NX = ""
3485 flags.NX = ""
3486 lct.NX = ""
3487 Status.nx = ""
3488 call _MasterpasswdWrite
3489 call _PasswordDBRewrite
3490
3491 if pwd_mkdbRC = 0 then do
3492 if \VRGet("CB_UnixUserOnly","set") then do
3493 call _useraddsmb
3494 if SecondStage then do
3495 command = ""
3496 newflags = ""
3497 if VRGet("EF_Description","value") <> "" then command = ' --account-desc="'VRGet("EF_Description","value")'" '
3498 if VRGet("CB_Password_doesnt_expire","set") then newFlags = NewFlags||"X"
3499 if VRGet("CB_Deactivated","set") then newFlags = NewFlags||"D"
3500 if NewFlags <> "" then command = command||' -c "['NewFlags']"'
3501 say ' 'samba.!pdbeditexe' --user='Username.nx' --modify 'command' 'DebugLevel' 2>'samba.!error' 1>'samba.!msg
3502 address cmd samba.!pdbeditexe' --user='Username.nx' --modify 'command' 'DebugLevel' 2>'samba.!error' 1>'samba.!msg
3503
3504 if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */
3505 end
3506/* if GID.NX <> UID.NX then call _SmbGroupMembersSync GID.NX
3507 else call _SmbGroupMembersSync 513
3508 call _GroupWrite
3509 call _ContGroupsPopulate */
3510 end
3511 end
3512 call PB_Refresh_Click
3513
3514 call AddUser_Close
3515 IF options.!debug == 1 THEN say 'PB_AddUserOK_Click done.'
3516return
3517
3518/*:VRX PB_ChooseHome_Click
3519*/
3520PB_ChooseHome_Click:
3521 TargetDir = _DirDialog("",Samba.!homes)
3522 if TargetDir = "" then return
3523 ok = VRSet("EF_Home","value", TargetDir)
3524 drop TargetDir
3525return
3526
3527/*:VRX PB_CreateHome_Click
3528*/
3529PB_CreateHome_Click:
3530 if translate(VRGet("EF_Home","Value")) = "\NONEXISTENT" | translate(VRGet("EF_Home","Value")) = "\DEV\NULL" then return
3531 ok = SysMkDir(VRGet("EF_Home","Value"))
3532 call EF_Home_Change
3533return
3534
3535/*:VRX PB_Exit_Click
3536*/
3537PB_Exit_Click:
3538 say 'start PB_Cancel_Click'
3539 Call Quit
3540 say 'done PB_Cancel_Click'
3541return
3542
3543/*:VRX PB_GroupAddCancel_Click
3544*/
3545PB_GroupAddCancel_Click:
3546 call AddGroup_Close
3547return
3548
3549/*:VRX PB_GroupAddOK_Click
3550*/
3551PB_GroupAddOK_Click:
3552 if \UnixGroupOnly then do
3553 if VRGet("EF_Comment","Value") <> "" then Comment = ' -C "'VRGet("EF_Comment","Value")'"'
3554 else Comment = ""
3555 address cmd samba.!netexe' rpc group add "'VRGet("EF_GroupName","Value")'" 'Comment' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3556 if RC <> 0 then call _SambaShowError
3557 else call _SambaShowMsg
3558 end
3559 else do
3560 if VRGet("CB_AutomaticGGID","set")
3561 then call _kLibcGroupAdd VRGet("EF_GroupName","Value") , _GetNextGID()
3562 else call _kLibcGroupAdd VRGet("EF_GroupName","Value") , VRget("EF_GGID","Value")
3563 call PB_Save_Click
3564 end
3565 call PB_Refresh_Click
3566 call AddGroup_Close
3567return
3568
3569/*:VRX PB_GroupMapCancel_Click
3570*/
3571PB_GroupMapCancel_Click:
3572 call MapGroup_Close
3573return
3574
3575/*:VRX PB_GroupMapOK_Click
3576*/
3577PB_GroupMapOK_Click:
3578 if VRGet("EF_NTGRoupComment","value") <> "" then Comment = ' comment="'VRGet("EF_NTGRoupComment","value")'"'
3579 else Comment = ""
3580/* net groupmap add rid=512 ntgroup="Domain Admins" unixgroup="root" type=domain */
3581
3582say address cmd samba.!netexe' groupmap add rid='VRGet("EF_NTRID","Value")' ntgroup="'VRGet("EF_NTGroupName","Value")'" unixgroup="'GroupName.SelGnr'" type='NTGroupType' 'Comment' 'debuglevel
3583 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
3584 if RC <> 0 then call _SambaShowError
3585 else do
3586 call _SambaShowMsg
3587 blGusers = translate(Gusers.SelGnr,' ',',')
3588 do I = 1 to words(blGusers)
3589 address cmd samba.!netexe' rpc group addmem "'VRGet("EF_NTGroupName","Value")'" 'word(BlGusers,I)' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3590 if RC <> 0 then call _SambaShowError
3591 else call _SambaShowMsg
3592 say samba.!netexe' RC = 'RC
3593 end
3594 end
3595 call PB_Refresh_Click
3596 call MapGroup_Close
3597return
3598
3599/*:VRX PB_GroupMembersOK_Click
3600*/
3601PB_GroupMembersOK_Click:
3602 IF options.!debug == 1 THEN say 'PB_Group_MembersOK_Click started.'
3603 call Group_Members_Close
3604 IF options.!debug == 1 THEN say 'PB_Group_MembersOK_Click done.'
3605return
3606
3607/*:VRX PB_Help_Click
3608*/
3609PB_Help_Click:
3610 Msg.Title = VRGet("Main", "Caption")
3611 Msg.Type = "I"
3612 Msg.Text = "Not implemented"
3613 call _ShowMsg
3614return
3615
3616/*:VRX PB_JoinCancel_Click
3617*/
3618PB_JoinCancel_Click:
3619 call Join_Group_Close
3620return
3621
3622/*:VRX PB_JoinOK_Click
3623*/
3624PB_JoinOK_Click:
3625 ok = VRMethod( "LB_Groups", "GetSelectedStringList", SelGroups. )
3626 if SelGroups.0 = 0 then return
3627 do I = 1 to SelGroups.0
3628 ok = VRCopyFile(samba.!group, samba.!group'.bak')
3629 say samba.!netexe' rpc addmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3630 address cmd samba.!netexe' rpc group addmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3631 if RC <> 0 then do
3632 call _SambaShowError
3633 ok = VRCopyFile(samba.!group'.bak', samba.!group)
3634 end
3635 else call _SambaShowMsg
3636
3637/* call _SmbGroupMembersSync SelGroups.I
3638 call _GroupWrite */
3639 end
3640 call Join_Group_Close
3641 call PB_Refresh_Click
3642return
3643
3644/*:VRX PB_LeaveCancel_Click
3645*/
3646PB_LeaveCancel_Click:
3647 call Leave_Group_Close
3648return
3649
3650/*:VRX PB_LeaveOK_Click
3651*/
3652PB_LeaveOK_Click:
3653 ok = VRMethod( "LB_LeaveGroups", "GetSelectedStringList", SelGroups. )
3654 if SelGroups.0 = 0 then return
3655 do I = 1 to SelGroups.0
3656 ok = VRCopyFIle(samba.!group, samba.!group'.bak')
3657 say samba.!netexe' rpc delmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3658 address cmd samba.!netexe' rpc group delmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3659 if RC <> 0 then do
3660 call _SambaShowError
3661 ok = VRCopyFile(samba.!group'.bak', samba.!group)
3662 end
3663 else call _SambaShowMsg
3664/* call _SmbGroupMembersSync SelGroups.I
3665 call _GroupWrite */
3666 end
3667 call Leave_Group_Close
3668 call PB_Refresh_Click
3669return
3670
3671/*:VRX PB_LOGIN_CANCEL_Click
3672*/
3673PB_LOGIN_CANCEL_Click:
3674 say " Login Abort"
3675 call SW_LOGIN_Close
3676 exit 0
3677return
3678
3679/*:VRX PB_LOGIN_OK_Click
3680*/
3681PB_LOGIN_OK_Click:
3682 IF options.!debug == 1 THEN say " SW_LOGIN OK started"
3683 Credentials.!Username = VRGet("EF_LoginUser","Value")
3684 Credentials.!Password = VRGet("EF_LoginPassword","Value")
3685
3686 if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0
3687 then UserCred = '--user='Credentials.!username'%'Credentials.!password
3688 else UserCred = '--user='Credentials.!username'%%'Credentials.!password
3689
3690 Call SW_LOGIN_Close
3691 IF options.!debug == 1 THEN say " SW_LOGIN OK done"
3692return
3693
3694/*:VRX PB_pdbeditConsole_Click
3695*/
3696PB_pdbeditConsole_Click:
3697 Buttons.1 = NLVGetMessage(2)
3698 Buttons.2 = NLVGetMessage(3)
3699 Buttons.0 = 2
3700 command = ' --account-desc= --fullname --homedir= --drive= --script= --profile= --domain= -c "[NDHLX]"'
3701 id = VRPrompt( VRWindow(), 'pdbedit --user='Username.CurUserNr' --modify', "command", "pdbedit Console", "Buttons.", buttons.1, buttons.2 )
3702 if id = 2 then return
3703 say samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'command' 'DebugLevel' 2>'samba.!error
3704 address cmd samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'command' 'DebugLevel' 2>'samba.!error
3705 if RC <> 0 then call _SambaShowError
3706 call _UserPropertiesGet Username.CurUserNr
3707return
3708
3709/*
3710Settable account flags
3711 N: No password required
3712 D: Account disabled
3713 H: Home directory required
3714 L: Automatic Locking
3715 X: Password does not expire
3716
3717Account Types:
3718 U: Regular user account
3719 T: Temporary duplicate of other account
3720 M: MNS logon user account
3721 W: Workstation Trust Account
3722 S: Server Trust Account
3723 I: Domain Trust Account
3724
3725 */
3726/*:VRX PB_PolReset_Click
3727*/
3728PB_PolReset_Click:
3729 say samba.!pdbeditexe' --policies-reset 'DebugLevel' 1>'samba.!msg
3730 address cmd samba.!pdbeditexe' --policies-reset 'DebugLevel' 1>'samba.!msg
3731 call _SambaShowMsg "description"
3732return
3733
3734/*:VRX PB_PolUpdate_Click
3735*/
3736PB_PolUpdate_Click:
3737 say samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" -C 'VRGet("EF_PolValue","Value")' 'DebugLevel' 1>'samba.!msg
3738 address cmd samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" -C 'VRGet("EF_PolValue","Value")' 'DebugLevel' 1>'samba.!msg
3739 call _SambaShowMsg "description"
3740return
3741
3742/*:VRX PB_Refresh_Click
3743*/
3744PB_Refresh_Click:
3745 call _Refresh
3746return
3747
3748/*:VRX PB_RPC_Click
3749*/
3750PB_RPC_Click:
3751 Buttons.1 = NLVGetMessage(2)
3752 Buttons.2 = NLVGetMessage(3)
3753 Buttons.0 = 2
3754 command = 'group'
3755 id = VRPrompt( VRWindow(), "net rpc", "command", "net rpc Console", "Buttons.", buttons.1, buttons.2 )
3756 if id = 2 then return
3757 say samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3758 address cmd samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg
3759 if RC <> 0 then call _SambaShowError; else call _SambaShowMsg
3760 call PB_Refresh_Click
3761return
3762
3763/*:VRX PB_Save_Click
3764*/
3765PB_Save_Click:
3766 IF options.!debug == 1 THEN say 'PB_Save_Click() started'
3767 call _MasterpasswdWrite
3768 call _GroupWrite
3769 call _PasswordDBRewrite
3770 call _SmbUserMapWrite
3771 IF options.!debug == 1 THEN say 'PB_Save_Click() done'
3772return
3773
3774/*:VRX PB_upCancel_Click
3775*/
3776PB_upCancel_Click:
3777 call UserProperties_Close
3778return
3779
3780/*:VRX PB_upSave_Click
3781*/
3782PB_upSave_Click:
3783/* U: Regular user account
3784 T: Temporary duplicate of other account
3785 M: MNS logon user account
3786 W: Workstation Trust Account
3787 S: Server Trust Account
3788 I: Domain Trust Account */
3789
3790 /* we mask out flags that cannot be modified anyway here */
3791 CurFlags = translate(CurFlags,' ','UTMWSI')
3792
3793 if VRGet("CB_upResetLogonHours", "set") then newcommand = newcommand||' -Z'
3794
3795 say samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'newcommand' -c "['CurFlags']" 'DebugLevel' 2>'samba.!error /* ' 1>'samba.!msg */
3796 address cmd samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'newcommand' -c "['CurFlags']" 'DebugLevel' 2>'samba.!error /* ' 1>'samba.!msg */
3797 if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */
3798
3799 else do
3800 if VRGet("EF_upPassword","Value") <> "" | VRGet("EF_upPassword_repeat","Value") <> "" then do /* Password change! */
3801 if VRGet("EF_upPassword","Value") <> VRGet("EF_upPassword_repeat","Value") then do
3802 Msg.type = "E"
3803 Msg.Text = NLVGetMessage( 104 )
3804 call _ShowMsg
3805 return
3806 end
3807 else do
3808 if length(VRGet("EF_upPassword","Value")) < MinPWLength then do
3809 Msg.type = "E"
3810 Msg.Text = NLVGetMessage( 117 )
3811 call _ShowMsg
3812 return
3813 end
3814 else do
3815 pwdfile = TempDir'newpwd'
3816 call lineout pwdfile, VRGet("EF_upPassword","value")
3817 call lineout pwdfile, VRGet("EF_upPassword","value")
3818 ok = stream(pwdfile,"c","close")
3819 say samba.!smbpasswdexe' -a 'Username.CurUserNr' -s <'pwdfile' 2>'samba.!error
3820 address cmd samba.!smbpasswdexe' -a 'Username.CurUserNr' -s <'pwdfile' 2>'samba.!error' 1>'samba.!msg
3821 smbpasswdrc = rc
3822 if rc <> 0 then call _SambaShowError
3823 else call _SambaShowMsg
3824 ok = SysFileDelete(pwdfile)
3825 if SwatAuth then do
3826 /* we always remove the old swat */
3827 say ' 'samba.!htpasswdexe' -D "'swatusers'" 'Username.CurUserNr
3828 address cmd samba.!htpasswdexe' -D "'swatusers'" 'Username.CurUserNr /* ' 2>'samba.!error' 1>'samba.!msg
3829 if rc <> 0 then call _SambaShowError; else call _SambaShowMsg */
3830
3831 if VRGet("CB_upSWAT_Allowed","Set") then do
3832 if VRFileExists(swatusers) then cFlag = ""; else cFlag="c"
3833 say ' 'samba.!htpasswdexe' -b'cFLag' "'swatusers'" 'Username.CurUserNr' **********'
3834 address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" 'Username.CurUserNr' 'VRGet("EF_upPassword","value")' 2>'samba.!error' 1>'samba.!msg
3835 if rc <> 0 then call _SambaShowError
3836 else call _SambaShowMsg
3837 end
3838 end
3839 if settings.!WriteMasterPwd = 1 then do
3840 call rxFuncAdd "Crypt", "RxCrypt", "RxCrypt"
3841 itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
3842 salt = ""
3843 do i = 1 to 8
3844 salt = salt || substr( itoa64, random( 0, 63 ) + 1, 1 )
3845 end
3846 password.CurUserNr = Crypt(VRGet("EF_upPassword","Value"), salt )
3847 call _UserRecWriteBackToStems
3848 call PB_Save_Click
3849 end
3850 end
3851 end
3852 end
3853 if pos("--fullname", newcommand) > 0 & Settings.!SyncFullName = 1 then do
3854 parse var newcommand dummy '--fullname="'NewGECOS'"' dummy
3855 GECOS.CurUserNr = NewGECOS
3856 SyncedFullName = 1
3857 end
3858 call UserProperties_Close
3859 end
3860return
3861
3862/*:VRX PushbackAll
3863*/
3864PushbackAll:
3865 Pages = 4
3866 /* Tab distance from top */
3867 TabTop = 20
3868 TabWidth = VRMethod( "Screen", "PixelsToTwips", 78 )
3869 TabHeight= VRMethod( "Screen", "PixelsToTwips", 24 )
3870
3871 /* Page Position */
3872 PageLeft = 120
3873 PageTop = PageLeft + TabTop + 330
3874
3875 /* Page size */
3876 PageHeight = 3000
3877 PageWidth = 3000
3878 ok = VRset("DT_PageName", "Caption", "")
3879 ok = VRSet("GB_Main","Left", 0)
3880 ok = VRSet("GB_Main","Top", TabTop+230)
3881 do I = 1 to Pages
3882 ok = VRSet("Page_"I,"BackColor", "<default>")
3883 ok = VRSet("TAB_"I,"Top", TabTop)
3884 ok = VRSet("TAB_"I,"PicturePath","#2"||I||";#2"||I)
3885 ok = VRSet("TAB_"I,"Left",TabWidth*(I-1)+PageLeft)
3886 ok = VRSet("TAB_"I,"Width",TabWidth)
3887 ok = VRSet("TAB_"I,"Height",TabHeight)
3888 ok = VRSet("Page_"I,"Height", max(PageHeight,VRget("GB_Main2","Height")-600))
3889 ok = VRSet("Page_"I,"Width", max(PageWidth,VRget("GB_Main2","Width")-450))
3890 ok = VRSet("Page_"I,"Left", PageLeft)
3891 ok = VRSet("Page_"I,"Top", PageTop)
3892 ok = VRSet("Page_"I,"Visible", 0)
3893 end
3894return
3895
3896/*:VRX Quit
3897*/
3898Quit:
3899 if VRGet("Main","WindowState") = "Maximized"|,
3900 VRGet("Main","WindowState") = "Minimized" then ok = VRMethod("Main", "Restore")
3901 call _IniWrite
3902 ok = VRREdirectStdio("OFF")
3903 call _SambaFinish
3904 ok = SysFileDelete(smbdoutput)
3905 if VRParseFileName(samba.!smbpasswd,"DP")||'\' = TempDir then do
3906 ok = SysFileDelete(samba.!smbpasswd)
3907 end
3908 window = VRWindow()
3909 call VRSet window, "Shutdown", 1
3910 drop window
3911return
3912
3913/*:VRX RB_NTGroupType_builtin_Click
3914*/
3915RB_NTGroupType_builtin_Click:
3916 NTGroupType = 'builtin'
3917return
3918
3919/*:VRX RB_NTGroupType_domain_Click
3920*/
3921RB_NTGroupType_domain_Click:
3922 NTGroupType = 'domain'
3923return
3924
3925/*:VRX RB_NTGroupType_local_Click
3926*/
3927RB_NTGroupType_local_Click:
3928 NTGroupType = 'local'
3929return
3930
3931/*:VRX SW_LOGIN_Close
3932*/
3933SW_LOGIN_Close:
3934 call SW_LOGIN_Fini
3935return
3936
3937/*:VRX SW_LOGIN_Create
3938*/
3939SW_LOGIN_Create:
3940 call SW_LOGIN_Init
3941 CALL NLVSetText 'SW_LOGIN', 'Caption', 31
3942 CALL NLVSetText 'DT_LoginUser', 'Caption', 32
3943 CALL NLVSetText 'DT_LoginPassword','Caption', 33
3944 CALL NLVSetText 'PB_LOGIN_OK', 'Caption', 2
3945 CALL NLVSetText 'PB_LOGIN_CANCEL', 'Caption', 3
3946
3947 if Credentials.!Username = ""
3948 then ok = VRSet("EF_LoginUser","Value", value("USER",,"OS2ENVIRONMENT"))
3949 else ok = VRSet("EF_LoginUser","Value", Credentials.!Username)
3950
3951 if \_UserIsValid(VRGet("EF_LoginUser","Value")) & value("USER",,"OS2ENVIRONMENT") <> "" then do
3952 Msg.Title =VRGet("Main", "caption")
3953 Msg.Type = "E"
3954 Msg.Text = NLVGetMessage(111, VRGet("EF_LoginUser","Value"))
3955 call _ShowMsg
3956 ok = VRSet("EF_LoginUser","Value","root")
3957 end
3958
3959 if VRGet("EF_LoginUser","Value") <> "" then ok = VRMethod("EF_LoginPassword","Setfocus")
3960return
3961
3962/*:VRX SW_LOGIN_Fini
3963*/
3964SW_LOGIN_Fini:
3965 window = VRInfo( "Window" )
3966 call VRDestroy window
3967 drop window
3968return
3969/*:VRX SW_LOGIN_Init
3970*/
3971SW_LOGIN_Init:
3972 window = VRInfo( "Object" )
3973 if( \VRIsChildOf( window, "Notebook" ) ) then do
3974 call VRMethod window, "CenterWindow"
3975 call VRSet window, "Visible", 1
3976 call VRMethod window, "Activate"
3977 end
3978 drop window
3979return
3980
3981/*:VRX TAB_1_Click
3982*/
3983TAB_1_Click:
3984 call Activate 1
3985return
3986
3987/*:VRX TAB_2_Click
3988*/
3989TAB_2_Click:
3990 call Activate 2
3991return
3992
3993/*:VRX TAB_3_Click
3994*/
3995TAB_3_Click:
3996 call Activate 3
3997return
3998
3999/*:VRX TAB_4_Click
4000*/
4001TAB_4_Click:
4002 call Activate 4
4003return
4004
4005/*:VRX TAB_5_Click
4006*/
4007TAB_5_Click:
4008 call Activate 5
4009return
4010
4011/*:VRX UserProperties_Close
4012*/
4013UserProperties_Close:
4014 call UserProperties_Fini
4015 if SyncedFullName = 1 | SyncedPrimGID = 1 then call PB_Save_Click
4016 call PB_Refresh_Click
4017return
4018
4019/*:VRX UserProperties_Create
4020*/
4021UserProperties_Create:
4022 call UserProperties_Init
4023 CALL NLVSetText 'UserProperties', 'Caption', 120
4024
4025 upTabWidth = VRMethod( "Screen", "PixelsToTwips", 136 )
4026 upTabHeight= VRMethod( "Screen", "PixelsToTwips", 24 )
4027
4028 ok = VRset("IPB_Accountflags","Width", upTabWidth)
4029 ok = VRset("IPB_Profile","Width", upTabWidth)
4030 ok = VRset("IPB_Memberships","Width", upTabWidth)
4031
4032 ok = VRset("IPB_Accountflags","Top", 40)
4033 ok = VRset("IPB_Profile", "Top", 40)
4034 ok = VRset("IPB_Memberships", "Top", 40)
4035
4036 ok = VRset("IPB_Accountflags","Left", upTabWidth*0+40)
4037 ok = VRset("IPB_Profile", "Left", upTabWidth*1+40)
4038 ok = VRset("IPB_Memberships", "Left", upTabWidth*2+40)
4039
4040 ok = VRset("IPB_Accountflags","Height", upTabHeight)
4041 ok = VRset("IPB_Profile", "Height", upTabHeight)
4042 ok = VRset("IPB_Memberships", "Height", upTabHeight)
4043
4044 CALL NLVSetText 'PB_upSave', 'Caption', 10
4045 CALL NLVSetText 'PB_upCancel', 'Caption', 3
4046 ok = VRSet("PB_pdbeditconsole",'Caption', "pdbedit "||word(NLVGetMessage(23),2))
4047
4048 CALL NLVSetText 'DT_upAccountType', 'Caption', 55
4049 CALL NLVSetText 'CB_upNoPassword', 'Caption', 20
4050 CALL NLVSetText 'DT_upPassword', 'Caption', 33
4051 CALL NLVSetText 'DT_upPassword_Repeat', 'Caption', 43
4052
4053 CALL NLVSetText 'CB_upMust_change_password', 'Caption', 46
4054 CALL NLVSetText 'CB_upCannot_change_password', 'Caption', 47
4055 CALL NLVSetText 'CB_upPassword_doesnt_expire', 'Caption', 48
4056 CALL NLVSetText 'CB_upDeactivated', 'Caption', 49
4057 CALL NLVSetText 'CB_upResetLogonHours', 'Caption', 54
4058 CALL NLVSetText 'CB_upSWAT_Allowed', 'Caption', 35
4059
4060 ok = VRSet('CB_upSWAT_Allowed',"Enabled",swatAuth)
4061
4062 CALL NLVSetText 'DT_upGroups', 'Caption', 56
4063 CALL NLVSetText 'CB_EditableFieldsOnly', 'Caption', 45
4064
4065 upNrFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(130))
4066 upTypeFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(57))
4067 upValueFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(58))
4068 upCommandFH= VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(59))
4069
4070 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upNrFH, "Visible", 0)
4071 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upTypeFH, "ReadOnly", 1)
4072 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upValueFH, "ReadOnly", 0)
4073 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upCommandFH, "ReadOnly", 1)
4074 ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upCommandFH, "Visible", 0)
4075
4076 ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "Selected." )
4077 if Selected.0 = 0 then return
4078 CurUserNr = VRMethod("CN_Users","GetFieldData", Selected.1, NrFH)
4079 call IPB_AccountFlags_Click
4080
4081 ok = VRMethod("PB_upCancel", "SetFocus" )
4082
4083 SyncedPrimGID = 0
4084 SyncedFullName = 0
4085
4086 MinPWLength = _PolicyGet("min password length")
4087
4088 call _UserPropertiesGet Username.CurUserNr
4089 newcommand = ""
4090return
4091
4092/*:VRX UserProperties_Fini
4093*/
4094UserProperties_Fini:
4095 window = VRInfo( "Window" )
4096 call VRDestroy window
4097 drop window
4098return
4099/*:VRX UserProperties_Init
4100*/
4101UserProperties_Init:
4102 window = VRInfo( "Object" )
4103 if( \VRIsChildOf( window, "Notebook" ) ) then do
4104 call VRMethod window, "CenterWindow"
4105 call VRSet window, "Visible", 1
4106 call VRMethod window, "Activate"
4107 end
4108 drop window
4109return
4110
Note: See TracBrowser for help on using the repository browser.