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

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

GUI tools: smbusers Version 0.9.1

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