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

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

GUI-Tools: SSCC 1.0.0, SMBUsers 0.9.8 several fixes, rest

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