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