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

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

smbusers.exe: Change password now also respects minimum password length policy

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