/*:VRX Main */ /* Main */ Main: /* Process the arguments. Get the parent window. */ parse source . calledAs . parent = "" argCount = arg() argOff = 0 if( calledAs \= "COMMAND" )then do if argCount >= 1 then do parent = arg(1) argCount = argCount - 1 argOff = 1 end end; else do call VROptions 'ImplicitNames' call VROptions 'NoEchoQuit' end InitArgs.0 = argCount if( argCount > 0 )then do i = 1 to argCount InitArgs.i = arg( i + argOff ) end drop calledAs argCount argOff /* Load the windows */ call VRInit parse source . . spec _VREPrimaryWindowPath = , VRParseFileName( spec, "dpn" ) || ".VRW" _VREPrimaryWindow = , VRLoad( parent, _VREPrimaryWindowPath ) drop parent spec if( _VREPrimaryWindow == "" )then do call VRMessage "", "Cannot load window:" VRError(), , "Error!" _VREReturnValue = 32000 signal _VRELeaveMain end /* Process events */ call Init signal on halt do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) ) _VREEvent = VREvent() interpret _VREEvent end _VREHalt: _VREReturnValue = Fini() call VRDestroy _VREPrimaryWindow _VRELeaveMain: call VRFini exit _VREReturnValue VRLoadSecondary: __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 ) if __vrlsWait then do call VRFlush end __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) ) if __vrlsHWnd = '' then signal __vrlsDone if __vrlsWait \= 1 then signal __vrlsDone call VRSet __vrlsHWnd, 'WindowMode', 'Modal' __vrlsTmp = __vrlsWindows.0 if( DataType(__vrlsTmp) \= 'NUM' ) then do __vrlsTmp = 1 end else do __vrlsTmp = __vrlsTmp + 1 end __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd ) __vrlsWindows.0 = __vrlsTmp do while( VRIsValidObject( VRWindow() ) = 1 ) __vrlsEvent = VREvent() interpret __vrlsEvent end __vrlsTmp = __vrlsWindows.0 __vrlsWindows.0 = __vrlsTmp - 1 call VRWindow __vrlsWindows.__vrlsTmp __vrlsHWnd = '' __vrlsDone: return __vrlsHWnd /*:VRX __VXREXX____APPENDS__ */ __VXREXX____APPENDS__: /* #append U:\Develop\Samba\guitools-2.0\shared\nlv.vrs #append U:\Develop\Samba\guitools-1.0\shared\inittempDir.vrs #append U:\Develop\Samba\guitools-1.0\shared\sambainit.vrs #append U:\Develop\Samba\guitools-1.0\shared\swat.vrs */ return /*:VRX _ColumnShow */ _ColumnShow: userdata = VRGet(VRInfo("OBject"),"Userdata") parse var userdata Container '|' fieldh '|' VisStatus ok = VRMethod(Container,"SetFieldAttr", fieldh, "Visible", \VisStatus ) return /*:VRX _ColumnsMenu */ _ColumnsMenu: Container = arg(1) ok = VRMethod(Container, "GetFieldList", "Fields." ) do I = 1 to 17 if I <= fields.0 then do /* say "Columns_"||right("0"||I,2)' 'VRMethod(Container, "GetFieldAttr", fields.I, "Title" ) */ ok = VRset("Columns_"||right("0"||I,2), "Visible", 1) ok = VRset("Columns_"||right("0"||I,2), "Caption", VRMethod(Container, "GetFieldAttr", fields.I, "Title" )) ok = VRset("Columns_"||right("0"||I,2), "Checked", VRMethod(Container, "GetFieldAttr", fields.I, "Visible" )) ok = VRset("Columns_"||right("0"||I,2), "Userdata", Container'|'fields.I'|'VRMethod(Container, "GetFieldAttr", fields.I, "Visible" )) end else ok = VRset("Columns_"||right("0"||I,2), "Visible", 0) end ok = VRMethod( "Columns", "Popup", , , "", "" ) return /*:VRX _ContainerPopulate */ _ContainerPopulate: IF options.!debug == 1 THEN say '_ContainerPopulate() started' ok = VRSet("CN_Users","Painting", 0 ) ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." ) if SelRH.0 <> 0 then SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH) else SelNr = 0 IF options.!debug == 1 then say ' Selected User Nr = 'SelNr ok = VRMethod("CN_Users","RemoveRecord", "ALL") drop RH. do i = 1 to username.0 RH.i = VRMethod("CN_Users", "AddRecord", , , username.I , "#29" ) 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) ok = VRMethod("CN_Users","SetFieldData", RH.i, xpwFH, password.i,xlcFH,LoginClass.I,xcpwFH, pwchange.I,xDeactFH, deact.I ) /* smbpasswd fields */ ok = VRMethod("CN_Users","SetFieldData", RH.i, FLagsFH, flags.I, LMHashFH, LMHash.I,NTHashFH, NTHash.I, LCTFH, LCT.I) /* smbusermap field */ ok = VRMethod( "CN_Users", "SetFieldData", RH.i, MapToFH, MapTo.I) /* private field */ ok = VRMethod( "CN_Users", "SetFieldData", RH.i, StatusFH, Status.I) if (flags.i = "" & settings.!SmbOnly) then do ok = VRMethod( "CN_Users", "SetRecordAttr", RH.i, "Visible", 0) end end RH.0 = username.0 if SelNr <= I & SelNr <> 0 & Username.0 > 0 then do MSelNr = Min(SelNr, Username.0) ok = VRMethod("CN_Users", "SetRecordAttr", RH.MSelNr, "Selected", 1) end ok = VRMethod("CN_users", "Arrange") ok = VRSet("CN_Users","Painting", 1 ) IF options.!debug == 1 THEN say '_ContainerPopulate() done' return /*:VRX _ContainersInit */ _ContainersInit: /* User */ NrFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(130) ) FlagsFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(131) ) /* smbpasswd */ UsernameFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(132) ) /* master.passwd and smbpasswd */ xpwFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(133) ) /* master.passwd, not used */ UIDFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(134) ) /* master.passwd and smbpasswd */ GeCOSFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(135) ) /* master.passwd */ GIDFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(136) ) /* master.passwd */ xlcFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(137) ) /* master.passwd, not used */ xcpwFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(138) ) /* master.passwd, not used */ xDeactFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(139) ) /* master.passwd, not used */ HomeFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(140) ) /* master.passwd */ ShellFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(141) ) /* master.passwd, not used */ LMHashFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(142) ) /* smbpasswd */ NTHashFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(143) ) /* smbpasswd */ LCTFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(144) ) /* smbpasswd */ MapToFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(145) ) /* smbusermap */ StatusFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(146) ) /* ok = VRSet("CN_Users","LastSplitfield", MapToFH) ok = VRSet("CN_Users","SplitBarLeft", VRGet("CN_Users","Width")*0.90) */ ok = VRMethod("CN_Users","SetfieldAttr",NrFH, "ReadOnly", 1, "Justification", "Right") ok = VRMethod("CN_Users","SetfieldAttr",FlagsFH, "ReadOnly", 1) ok = VRMethod("CN_Users","SetfieldAttr",UserNameFH,"ReadOnly", 1) ok = VRMethod("CN_Users","SetfieldAttr",GIDFH, "Justification", "Right" ) ok = VRMethod("CN_Users","SetfieldAttr",UIDFH, "ReadOnly", 1, "Justification", "Right" ) ok = VRMethod("CN_Users","SetfieldAttr",LCTFH, "ReadOnly", 1) ok = VRMethod("CN_Users","SetfieldAttr",LMHashFH, "ReadOnly", 1) ok = VRMethod("CN_Users","SetfieldAttr",NTHashFH, "ReadOnly", 1) ok = VRMethod("CN_Users","SetfieldAttr",xpwFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",xlcFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",xcpwFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",xDeactFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",LMHashFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",NTHashFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",ShellFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",LCTFH, "Visible", 0) if samba.!smbusermap = "" then do ok = VRMethod("CN_Users","SetfieldAttr",MapToFH, "Visible", 0) ok = VRMethod("CN_Users","SetfieldAttr",MapToFH, "ReadOnly", 1) end /* master.passwd syntax: Username:password:UID:GID:Login-Class:Change pw in x seconds:Deactivate in x seconds:GECOS (Fullname):HOME:SHELL */ /* smbpasswd syntax: Username:UID:Lanman Password Hash:NT Password Hash:flags:LCT (Last Change Time) */ GNrFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(130) ) /* private */ GroupNameFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(150) ) /* group */ NTGroupNameFH= VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(151) ) /* net group */ GpasswdFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(152) ) /* group, not used */ GGIDFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(153) ) /* group */ GUsersFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(154) ) /* group */ SIDFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(155) ) /* net group */ RIDFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(156) ) /* net group */ NTCommentFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(157) ) /* net group */ NTGroupTypeFH= VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(158) ) /* net group */ GStatusFH = VRMethod( "CN_Groups", "AddField", "String", NLVGetMessage(159) ) /* private */ ok = VRMethod("CN_Groups","SetfieldAttr",GNrFH,"ReadOnly", 1, "Justification", "Right") ok = VRMethod("CN_Groups","SetfieldAttr",GroupnameFH,"ReadOnly", 1) ok = VRMethod("CN_Groups","SetfieldAttr",NTGroupnameFH,"ReadOnly", 1) ok = VRMethod("CN_Groups","SetfieldAttr",NTCommentFH,"ReadOnly", 1) ok = VRMethod("CN_Groups","SetfieldAttr",NTGroupTypeFH,"ReadOnly", 1) ok = VRMethod("CN_Groups","SetfieldAttr",SIDFH,"ReadOnly", 1) ok = VRMethod("CN_Groups","SetfieldAttr",SIDFH,"Visible", 0) ok = VRMethod("CN_Groups","SetfieldAttr",RIDFH,"ReadOnly", 1) ok = VRMethod("CN_Groups","SetfieldAttr",GGIDFH,"ReadOnly", 1, "Justification", "Right") ok = VRMethod("CN_Groups","SetfieldAttr",GPasswdFH, "Visible", 0) ok = VRMethod("CN_Groups","SetfieldAttr",GPasswdFH, "ReadOnly", 1) return /*:VRX _ContGroupsPopulate */ _ContGroupsPopulate: IF options.!debug == 1 then say '_ContGroupsPopulate() started.' ok = VRSet("CN_Groups","Painting", 0 ) ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." ) if SelGRH.0 <> 0 then SelGNr = VRMethod("CN_Users", "GetFieldData", SelGRH.1, GNrFH) else SelGNr = 0 IF options.!debug == 1 then say ' Selected Group Nr = 'SelGNr ok = VRMethod("CN_Groups","RemoveRecord", "ALL") drop GRH. do i = 1 to Groupname.0 GRH.i = VRMethod("CN_Groups", "AddRecord", , , Groupname.I , "#50" ) ok = VRMethod("CN_Groups","SetFieldData", GRH.i, GNrFH, I, GroupnameFH, Groupname.I, GGIDFH, GGid.I, GUsersFH, Gusers.I ) /* private field */ 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) if (RID.i = "" & settings.!SmbGroupsOnly) then do ok = VRMethod( "CN_Groups", "SetRecordAttr", GRH.i, "Visible", 0) end end GRH.0 = Groupname.0 if SelGNr <= I & SelGNr <> 0 & Groupname.0 > 0 then ok = VRMethod("CN_Groups", "SetRecordAttr", GRH.SelGNr, "Selected", 1) ok = VRMethod("CN_Groups", "Arrange") ok = VRSet("CN_Groups","Painting", 1 ) IF options.!debug == 1 then say '_ContGroupsPopulate() done.' return /*:VRX _DirDialog */ _DirDialog: procedure Title = arg(1) InitDir = arg(2) RC = RxFuncQuery("DRCtrlPickDirectory") if RC = 0 then do /* use DrCtrl if available */ MyDir=DRCtrlPickDirectory(InitDir, Title) end else do MyDir = VRFileDialog(VRWindow,Title, 'o', InitDir||'\dummy') if MyDir <> '' then MyDir = strip(filespec('D',MyDir)||Filespec('P',MyDir),'T','\') end return MyDir /*:VRX _GetNextGID */ _GetNextGID: procedure expose MinGGID GGID. say "_GetNextGID() started" do nextGID = minGGID to 65535 by 1 do i=1 to GGID.0 while GGID.i <> nextGID end if GGID.i <> nextGID then leave end say "_GetNextGID() done, returning "nextGID return nextGID /*:VRX _GetNextUID */ _GetNextUID: procedure expose MinUID UID. nextusername = translate(arg(1)) say "_GetNextUID() started" do nextUID = minUID to 65535 by 1 do i=1 to UID.0 while UID.i <> nextUID end if uid.i <> nextUID then leave end if translate(nextusername) = "ROOT" then NextUID = 0 if translate(nextusername) = "GUEST" then NextUID = 65534 if translate(nextusername) = "NOBODY" then NextUID = 65533 say "_GetNextUID() done, returning "nextUID return nextUID /*:VRX _GroupRead */ _GroupRead: IF options.!debug == 1 THEN say '_GroupRead() started' /* Read complete group file */ I = 0 do while lines(samba.!group) <> 0 groupline = strip(linein(samba.!group)) /* Skip comments */ if left(groupline,1) = "#" then iterate if left(groupline,1) = ";" then iterate /* parse fields into stem variables */ I = I + 1 parse var groupline groupname.I':'Gpasswd.I':'GGid.I':'Gusers.I GStatus.I ="" if pos(',,',GUsers.I) > 0 then GStatus.I='DOUBLE COMMA FOUND' if right(GUsers.I,1) <> ',' & Gusers.I <> "" then GStatus.I='MISSING TRAILING COMMA' do J = 1 to I - 1 if translate(groupname.J) = translate(groupname.I) then do gstatus.I = "DUPLICATE" leave end end blGUsers = translate(translate(Gusers.I,' ',',')) do J = 1 to Username.0 UPos = wordpos(translate(Username.J),blGusers) if Upos > 0 then blGUsers = delword(BlGusers,UPos,1) if GID.J = GGID.I & UPos = 0 then do Gusers.I = strip(Gusers.I||Username.J,,',')',' GStatus.I = 'MISSING USERS ADDED' end end if strip(BlGusers) <> "" then gstatus.I = "NONEXISTENT USER" end ok = stream(samba.!group,'c','close') NTGroupname. = "(klibc group)" NTComment. = "" NTGroupType. = "" RID. = "" SID. = "" /* set "stem roots" properly */ groupname.0 = I gpasswd.0 = I ggid.0 = I gusers.0 = I NTGroupname.0 = I NTComment.0 = I NTGroupType.0 = I SID.0 = I RID.0 = I /* our private stem */ gstatus.0 = I IF options.!debug == 1 THEN say '_GroupRead() done, read 'groupname.0' kLIBC groups' return /*:VRX _GroupRecWriteBackToStems */ _GroupRecWriteBackToStems: IF options.!debug == 1 THEN say '_GroupRecWriteBackToStems() started' Cur = VRMethod("CN_Groups","GetFieldData", GRH, GNrFH) Groupname.Cur = VRMethod("CN_Groups","GetFieldData", GRH, GroupnameFH) GGID.Cur = VRMethod("CN_Groups","GetFieldData", GRH, GGIDFH) GUsers.Cur = VRMethod("CN_Groups","GetFieldData", GRH, GusersFH) if Gusers.Cur = "," then Gusers.Cur = "" IF options.!debug == 1 THEN say '_GroupRecWriteBackToStems() done' return /*:VRX _GroupWrite */ _GroupWrite: IF options.!debug == 1 THEN say '_GroupWrite() started' newgroup = TempDir'group' ok = SysFileDelete(newgroup) call lineout newgroup, '# Created by smbusers Version 'word(VRGet("Main", "Hinttext"),2) call lineout newgroup, '# syntax:' call lineout newgroup, '# groupname:password:GID:user[,user,...,]' do I = 1 to groupname.0 /* say "GUsers."I"="Gusers.I */ if settings.!FixErrors then do if Gusers.I = "," then Gusers.I = "" if pos(',,',Gusers.I) > 0 then do blGUsers = translate(Gusers.I,' ',',') Gusers.I = "" do ii = 1 to words(blGusers) Gusers.I = GUsers.I||word(blGusers,II)||',' end end if Gusers.I <> "" & right(Gusers.I,1) <> ',' then GUsers.I = Gusers.I||',' end NewUsers = "" select when GStatus.I = "DUPLICATE" & settings.!FixErrors then iterate when GStatus.I = "NONEXISTENT USER" & settings.!FixErrors then do blGUsers = translate(translate(Gusers.I,' ',',')) do J = 1 to Username.0 UPos = wordpos(translate(Username.J),blGusers) if Upos > 0 then NewUsers = NewUsers||UserName.J',' end call lineout newgroup, groupname.I':'Gpasswd.I':'GGid.I':'strip(NewUsers,'L',',') end otherwise call lineout newgroup, groupname.I':'Gpasswd.I':'GGid.I':'strip(GUsers.I,'L',',') end end ok = stream(newgroup,'c','close') ok = VRCopyFile( samba.!group, samba.!group'.bak' ) ok = VRCopyFile( newgroup, samba.!group ) ok = SysFileDelete(newgroup) IF options.!debug == 1 THEN say '_GroupWrite() done' return /*:VRX _GUIINit */ _GUIINit: IF options.!debug == 1 THEN say '_GUIInit() started' ok = VRset("Main","Width",11000) call Paper_Init if datatype(Top) = 'NUM' then do ok = VRset("Main","Top",Top) ok = VRset("Main","Left",Left) ok = VRset("Main","Width",max(Width,11000)) ok = VRset("Main","Height",Height) end ok = VRSet("Main","Font", Font_Main) ok = VRSet("Main","Statusfont", Font_Status) ok = VRSet("Page_1","Font", Font_Page_1) ok = VRSet("Page_2","Font", Font_Page_2) ok = VRSet("Page_4","Font", Font_Page_3) ok = VRSet("Page_3","Font", Font_Page_4) ok = VRSet("Page_5","Font", Font_Page_5) Buttonwidth = VRMethod( "Screen", "PixelsToTwips", 32 ) ok = VRSet("CB_SmbOnly", "set", settings.!SmbOnly ) ok = VRSet("CB_SmbGroupsOnly", "set", settings.!SmbGroupsOnly ) ok = VRSet("CB_SyncFullName", "set", settings.!SyncFullName ) ok = VRSet("CB_SyncPrimGID", "set", settings.!SyncPrimGID ) ok = VRSet("CB_WriteMasterPwd", "set", settings.!WriteMasterPwd ) call _INILayoutRead "CN_Users" call _INILayoutRead "CN_Groups" if _ChkTempFreeSpace() < 262144 then do Msg.Type = "W" Msg.Text = NLVGetMessage(180, TempDir) call _ShowMsg end ok = VRSet("Main", "Visible", 1) IF options.!debug == 1 THEN say '_GUIInit() done' return /*:VRX _INILayoutRead */ _INILayoutRead: Container = arg(1) ok = VRMethod(Container, "GetFieldList", "Fields." ) Layout = VRGetIni( "Layout", Container, OurINI ) if Layout = "" then return do I = 1 to Fields.0 ok = VRMethod(Container, "SetFieldAttr", fields.I,"Visible", substr(Layout,I,1)) end return /*:VRX _INILayoutWrite */ _INILayoutWrite: Container = arg(1) ok = VRMethod(Container, "GetFieldList", "Fields." ) Layout = "" do I = 1 to fields.0 Layout = Layout||VRMethod(Container, "GetFieldAttr", fields.I, "Visible" ) end ok = VRSetIni( "Layout", Container , Layout, OurINI, 'NoClose' ) return /*:VRX _INIRead */ _INIRead: IF options.!debug == 1 THEN say '_INIRead() started' OurINI = strip(VRParseFileName(VRget("Application","Program"),'DP')'\SMBUSERS.INI',,'\') ok = SysFileTree(OurINI, INIFound.,'FO') if INIFound.0 = 1 then OurINI = VRParseFileName(INIFound.1,'DPNE') IF options.!debug == 1 THEN say 'OurINI = "'OurINI'"' Top = VRGetIni( "Pos", "Top", OurINI , 'NoClose') Left = VRGetIni( "Pos", "Left", OurINI , 'NoClose') Width = VRGetIni( "Pos", "Width", OurINI , 'NoClose') Height= VRGetIni( "Pos", "Height", OurINI , 'NoClose') Font_Page_1 = VRGetIni( "Fonts", "Page_1", OurINI , 'NoClose' ) Font_Page_2 = VRGetIni( "Fonts", "Page_2", OurINI , 'NoClose' ) Font_Page_3 = VRGetIni( "Fonts", "Page_4", OurINI , 'NoClose' ) Font_Page_4 = VRGetIni( "Fonts", "Page_3", OurINI , 'NoClose' ) Font_Page_5 = VRGetIni( "Fonts", "Page_5", OurINI , 'NoClose' ) Font_Main = VRGetIni( "Fonts", "Main", OurINI , 'NoClose' ) Font_Status = VRGetIni( "Fonts", "Statusfont", OurINI , 'NoClose' ) if Font_Page_1 = "" then Font_Page_1 = "8.Helv" if Font_Page_2 = "" then Font_Page_2 = "8.Helv" if Font_Page_3 = "" then Font_Page_3 = "8.Helv" if Font_Page_4 = "" then Font_Page_4 = "8.Helv" if Font_Page_5 = "" then Font_Page_5 = "8.Helv" if Font_Main = "" then Font_Main = "8.Helv" if Font_Status = "" then Font_Status = "8.Helv" settings.!SmbOnly = VRGetIni( "Settings", "SmbOnly", OurINI) if settings.!SmbOnly = "" then settings.!SmbOnly = 0 settings.!SmbGroupsOnly = VRGetIni( "Settings", "SmbGroupsOnly", OurINI) if settings.!SmbGroupsOnly = "" then settings.!SmbGroupsOnly = 0 settings.!FixErrors = VRGetIni( "Settings", "FixErrors", OurINI) if settings.!FixErrors = "" then settings.!FixErrors = 1 settings.!SyncFullName = VRGetIni( "Settings", "SyncFullName", OurINI) if settings.!SyncFullName = "" then settings.!SyncFullName = 1 settings.!SyncPrimGID = VRGetIni( "Settings", "SyncPrimGID", OurINI) if settings.!SyncPrimGID = "" then settings.!SyncPrimGID = 0 settings.!WriteMasterPwd = VRGetIni( "Settings", "WriteMasterPwd", OurINI) if settings.!WriteMasterPwd = "" then settings.!WriteMasterPwd = 1 options.!debug = VRGetIni( "Options", "Debug", OurINI) if options.!debug = "" then options.!debug = 0 ok = VRSet("CB_Debug","set",options.!Debug) if options.!Debug then ok = VRREdirectStdIO("ON") else ok = VRREdirectStdIO("OFF") smbdoutput = 'smbd.out' sambaver = '' MinUID = 100 MinGGID = 3000 msg = '' Credentials. = '' IF options.!debug == 1 THEN say '_INIRead() done' return /*:VRX _INIWrite */ _INIWrite: say 'start _INIWrite()' ok = VRSetIni( "Pos", "Top", VRGet("Main","Top"), OurINI, 'NoClose' ) ok = VRSetIni( "Pos", "Left", VRGet("Main","Left"), OurINI, 'NoClose' ) ok = VRSetIni( "Pos", "Width", VRGet("Main","Width"), OurINI, 'NoClose' ) ok = VRSetIni( "Pos", "Height", VRGet("Main","Height"), OurINI, 'NoClose' ) ok = VRSetIni( "Settings", "SmbOnly", settings.!SmbOnly, OurINI, 'NoClose' ) ok = VRSetIni( "Settings", "SmbGroupsOnly", settings.!SmbGroupsOnly, OurINI, 'NoClose' ) ok = VRSetIni( "Settings", "FixErrors", settings.!FixErrors, OurINI, 'NoClose' ) ok = VRSetIni( "Settings", "SyncFullName", settings.!SyncFullName, OurINI, 'NoClose' ) ok = VRSetIni( "Settings", "SyncPrimGID" , settings.!SyncPrimGID , OurINI, 'NoClose' ) ok = VRSetIni( "Settings", "WriteMasterPwd",settings.!WriteMasterPwd,OurINI, 'NoClose' ) ok = VRSetIni( "Options", "Debug", options.!debug, OurINI, 'NoClose' ) if VRget("CN_Users", "Font") <> "" then ok = VRset("Page_1", "Font", VRget("CN_Users", "Font")) if VRget("CN_Groups", "Font") <> "" then ok = VRset("Page_2", "Font", VRget("CN_Groups", "Font")) call _INILayoutWrite "CN_Users" call _INILayoutWrite "CN_Groups" ok = VRSetIni( "Fonts", "Page_1", VRGet("Page_1","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "Page_2", VRGet("Page_2","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "Page_4", VRGet("Page_4","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "Page_3", VRGet("Page_3","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "Page_5", VRGet("Page_5","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "Statusfont", VRGet("Main","Statusfont"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "Main", VRGet("Main","Font"), OurINI ) say 'done _INIWrite()' return /*:VRX _kLIBCGroupAdd */ _kLIBCGroupAdd: NewGroupName = arg(1) NewGroupGGID = arg(2) nx = Groupname.0 + 1 Groupname.0 = nx groupname.nx = NewGroupName Gpasswd.nx ="*" GGid.nx = NewGroupGGID Gusers.nx = "" NTGroupname.nx = "" NTComment.nx = "" RID.nx = "" gstatus.nx = "" return /*:VRX _LoadotherFuncs */ _LoadotherFuncs: IF options.!debug == 1 THEN say "_LoadotherFuncs() started" ok = VRRedirectStdIO("ON") /* ELSE ok = VRRedirectStdIO("OFF") */ /* what REXX script would be complete without this... */ call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs call rxfuncadd 'IniLoadFuncs', 'REXXINI', 'IniLoadFuncs' call IniLoadFuncs call RxFuncAdd 'PRLoadFuncs', 'PR1UTIL', 'PRLoadFuncs' call PRLoadFuncs /* Deal with DRCtrlxxx */ RC = RxFuncQuery("DRCtrlPickDirectory") if RC = 1 then do /* DRCtrlXXX not already registered */ /* Load DRCtrl functions */ ok = RxFuncAdd('DRCtrlLoadFuncs', 'drctl017', 'DRCtrlLoadFuncs') if ok = 0 then CALL DRCtrlLoadFuncs end IF options.!debug == 1 THEN say "_LoadotherFuncs() done" return /*:VRX _Login */ _Login: IF options.!debug == 1 THEN say "_Login() started" if Credentials.!username <> "" then do if \_UserIsValid(Credentials.!username) then do Msg.Type ="E" Msg.Title= VRget("Main","Caption") Msg.Text = NLVGetMessage(111, Credentials.!username ) call _ShowMsg Credentials.!username = "root" Credentials.!password = "" end end LoginStatus = "" EnterCredentials: if Credentials.!username = "" | Credentials.!password = "" then window = VRLoadSecondary( "SW_LOGIN", "W" ) if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0 then UserCred = '--user='Credentials.!username'%'Credentials.!password else UserCred = '--user='Credentials.!username'%%'Credentials.!password /* Lets see if the credentials are good */ ok = VRSet("Main", 'Pointer', 'Wait' ) say ' 'samba.!netexe' rpc user 'DebugLevel' 'UserCred' 1>'samba.!msg address cmd samba.!netexe' rpc user 'DebugLevel' 'UserCred' 1>'samba.!msg ok = VRSet("Main", 'Pointer', '' ) loginLine = linein(samba.!msg) ok = stream(samba.!msg,'c','close') /* If did not get a valid user back i.e. the first entry of the list, login was not successful */ if \_UserIsValid(strip(loginLine)) then do Msg.Title = NLVGetMessage(31)': 'Credentials.!username'@'copies('*',length(Credentials.!password)) Msg.Text = SysGetMessage(65) Msg.Type = "E" call _ShowMsg Credentials.!username = "" Credentials.!password = "" IF options.!debug == 1 THEN say '_Login() failed, credentials used were "'UserCred'"' signal EnterCredentials end IF options.!debug == 1 THEN say '_Login() succeeded, credentials used are "'UserCred'"' return /*:VRX _MasterpasswdRead */ _MasterpasswdRead: IF options.!debug == 1 THEN say '_MasterpasswdRead() started' /* Read complete master.passwd */ I = 0 do until lines(samba.!masterpasswd) = 0 userline = strip(linein(samba.!masterpasswd)) /* Skip comments */ if left(userline,1) = "#" then iterate if left(userline,1) = ";" then iterate /* parse fields into stem variables */ I = I + 1 parse var userline username.I':'password.I':'uid.I':'gid.I':'LoginClass.I':'pwchange.I':'deact.I':'gecos.I':'home.I':'shell.I Status.I ="" do J = 1 to I - 1 if translate(Username.J) = translate(Username.I) then do status.I = "DUPLICATE" leave end end end ok = stream(samba.!masterpasswd,'c','close') drop userline /* set "stem roots" properly */ username.0 = I password.0 = I uid.0 = I gid.0 = I loginclass.0= I pwchange.0 = I deact.0 = I gecos.0 = I home.0 = I shell.0 = I /* also smbpasswd stems */ lmhash. = '' nthash. = '' flags. = '' lct. = '' lmhash.0 = I nthash.0 = I flags.0 = I lct.0 = I /* smbusermap stem */ MapTo. = '' MapTo.0 = I /* our private stem */ status.0 = I IF options.!debug == 1 THEN say '_MasterpasswdRead() done, read 'username.0' users' return /*:VRX _MasterpasswdWrite */ _MasterpasswdWrite: IF options.!debug == 1 THEN say "_MasterpasswdWrite() started" newmasterpasswd = TempDir'master.passwd' ok = SysFileDelete(newmasterpasswd) call lineout newmasterpasswd, '# Created by smbusers Version 'word(VRGet("Main", "Hinttext"),2) call lineout newmasterpasswd, '# syntax:' call lineout newmasterpasswd, '# username:passwd:UID:GID:login-class:chg pw x sec:deact x sec:GECOS:home:shell' do I = 1 to username.0 select when Status.I = "DUPLICATE" & settings.!FixErrors then iterate when Status.I = "UID MISMATCH" then do 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 end when Status.I = "UNIX MISSING" & settings.!FixErrors then do call lineout newmasterpasswd, username.I':'password.I':'uid.I':'gid.I':'loginclass.I':'pwchange.I':'deact.I':'gecos.I':'home.I':'shell.I end otherwise call lineout newmasterpasswd, username.I':'password.I':'uid.I':'gid.I':'loginclass.I':'pwchange.I':'deact.I':'gecos.I':'home.I':'shell.I end end ok = stream(newmasterpasswd,'c','close') ok = VRCopyFile( samba.!masterpasswd, samba.!masterpasswd'.bak' ) ok = VRCopyFile( newmasterpasswd, samba.!masterpasswd ) ok = SysFileDelete(newmasterpasswd) IF options.!debug == 1 THEN say "_MasterpasswdWrite() done" return /*:VRX _MsgYesNo */ _MsgYesNo: say "_MsgYesNo() started" buttons.0 = 2 buttons.1 = NLVGetMessage(6) buttons.2 = NLVGetMessage(7) default = 2 buttons.default = NLVGetMessage(7) esc = 2 buttons.esc = NLVGetMessage(7) RC = VRMessage( VRWindow(), Msg.Text, Msg.Title,"Q","buttons.",default, esc ) say "_MsgYesNo() done, answer "RC return RC /*:VRX _NLVSetup */ _NLVSetup: call NLVSetup CALL NLVSetText 'Main', 'Caption', 1 CALL NLVSetText 'PB_Save', 'Caption', 10 CALL NLVSetText 'PB_Refresh', 'Caption', 11 CALL NLVSetText 'PB_Exit', 'Caption', 12 CALL NLVSetText 'PB_Help', 'Caption', 13 CALL NLVSetText 'PB_About', 'Caption', 14 CALL NLVSetText 'PB_RPC', 'Caption', 23 CALL NLVSetText 'PB_Save', 'Hinttext', 123 CALL NLVSetText 'PB_Refresh', 'Hinttext', 124 CALL NLVSetText 'PB_Exit', 'Hinttext', 125 CALL NLVSetText 'PB_Help', 'Hinttext', 126 CALL NLVSetText 'PB_About', 'Hinttext', 127 CALL NLVSetText 'PB_RPC', 'Hinttext', 128 CALL NLVSetText 'TAB_1', 'Userdata', 15 CALL NLVSetText 'TAB_2', 'Userdata', 16 CALL NLVSetText 'TAB_3', 'Userdata', 170 CALL NLVSetText 'TAB_4', 'Userdata', 24 CALL NLVSetText 'TAB_1', 'Hinttext', 28 CALL NLVSetText 'TAB_2', 'Hinttext', 29 CALL NLVSetText 'TAB_3', 'Hinttext', 170 CALL NLVSetText 'TAB_4', 'Hinttext', 30 CALL NLVSetText 'Page_1', 'Hinttext', 28 CALL NLVSetText 'Page_2', 'Hinttext', 29 CALL NLVSetText 'Page_3', 'Hinttext', 171 CALL NLVSetText 'Page_4', 'Hinttext', 30 CALL NLVSetText 'CB_SmbOnly', 'Caption', 17 CALL NLVSetText 'CB_SmbGroupsOnly', 'Caption', 21 CALL NLVSetText 'CB_SmbOnly', 'Hinttext', 121 CALL NLVSetText 'CB_SmbGroupsOnly', 'Hinttext', 122 CALL NLVSetText 'Contextmenu_UserDetailView', 'Caption', 118 CALL NLVSetText 'Contextmenu_UserSymbolView', 'Caption', 119 CALL NLVSetText 'ContextMenu_UserProperties', 'Caption', 120 CALL NLVSetText 'ContextMenu_UserAdd', 'Caption', 40 CALL NLVSetText 'ContextMenu_UserDel', 'Caption', 50 CALL NLVSetText 'ContextMenu_UserJoinGroup', 'Caption', 80 CALL NLVSetText 'ContextMenu_UserLeaveGroup', 'Caption', 85 CALL NLVSetText 'Contextmenu_GroupDetailView', 'Caption', 118 CALL NLVSetText 'Contextmenu_GroupSymbolView', 'Caption', 119 CALL NLVSetText 'ContextMenu_GroupMembers', 'Caption', 89 CALL NLVSetText 'ContextMenu_GroupAdd', 'Caption', 70 CALL NLVSetText 'ContextMenu_GroupDel', 'Caption', 75 CALL NLVSetText 'ContextMenu_GroupMap', 'Caption', 90 CALL NLVSetText 'ContextMenu_GroupUnmap','Caption', 95 CALL NLVSetText 'ContextMenu_GroupRebuildScript','Caption', 98 CALL NLVSetText 'ContextMenu_GroupWellknown','Caption', 92 CALL NLVSetText 'DT_Policy', 'Caption', 172 CALL NLVSetText 'DT_PolValue', 'Caption', 173 CALL NLVSetText 'PB_PolReset', 'Caption', 174 CALL NLVSetText 'PB_PolUpdate','Caption', 175 CALL NLVSetText 'CB_FixErrors', 'Caption', 25 CALL NLVSetText 'CB_SyncFullName', 'Caption', 26 CALL NLVSetText 'CB_SyncPrimGID', 'Caption', 27 CALL NLVSetText 'CB_WriteMasterPwd','Caption', 190 return /*:VRX _OnErrorDisable */ _OnErrorDisable: ok = VRSet("PB_Save","Enabled",0) ok = VRSet("PB_Refresh","Enabled",0) ok = VRSet("IPB_UserAdd","Enabled",0) ok = VRSet("IPB_UserDel","Enabled",0) ok = VRSet("IPB_UserLeaveGroup","Enabled",0) ok = VRSet("IPB_UserJoinGroup","Enabled",0) ok = VRSet("IPB_GroupAdd","Enabled",0) ok = VRSet("IPB_GroupDel","Enabled",0) ok = VRSet("IPB_GroupMap","Enabled",0) ok = VRSet("IPB_GroupUnmap","Enabled",0) return /*:VRX _ParseCommandLine */ _ParseCommandLine: IF options.!debug == 1 THEN SAY "_ParseCommandLine() started" CmdLine = VRGet("Application","Commandline") IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"' upCmdLine = translate(CmdLine) UserPos = 0 UserPos = pos('--USER=',upCmdLine) if UserPos > 0 then do IF options.!debug == 1 THEN SAY " --USER switch detected" UserPasswd = translate(word(substr(CmdLine,UserPos+7,),1),'%','|') parse var UserPasswd Credentials.!Username '%' Credentials.!password end else do UserPos = pos('-U ',upCmdLine) If UserPos > 0 then do IF options.!debug == 1 THEN SAY " -U switch detected" UserPasswd = translate(word(substr(CmdLine,UserPos+3,),1),'%','|') parse var UserPasswd Credentials.!Username '%' Credentials.!password end end IF options.!debug == 1 THEN say ' Username ="'Credentials.!Username'"' IF options.!debug == 1 THEN say ' Password ="'Credentials.!password'"' IF options.!debug == 1 THEN SAY "_ParseCommandLine() done" return /*:VRX _PathStrkLIBC */ _PathStrkLIBC: procedure PathStr = translate(arg(1),'/','\') PathStr = translate(left(PathStr,2),'$',':')||substr(PathStr,3) return PathStr /*:VRX _PathStrOS2 */ _PathStrOS2: procedure PathStr = translate(arg(1),'\','/') PathStr = translate(left(PathStr,2),':','$')||substr(PathStr,3) return PathStr /*:VRX _PoliciesPopulate */ _PoliciesPopulate: IF options.!debug == 1 THEN say '_PoliciesPopulate() started' say samba.!pdbeditexe' -P -?'DebugLevel' 1>'samba.!msg' 2>'samba.!error address cmd samba.!pdbeditexe' -P -?'DebugLevel' 2>'samba.!error do until lines(samba.!error) = 0 PolLine = linein(samba.!error) /* say polline */ select when pos(":",PolLine) > 0 then iterate when pos("!",PolLine) > 0 then iterate otherwise ok = VRMethod("DDCB_Policy","Addstring", PolLine) end end ok = stream(Samba.!error,'c','close') IF options.!debug == 1 THEN say '_PoliciesPopulate() done' return /*:VRX _PolicyGet */ _PolicyGet: IF options.!debug == 1 THEN say '_PoliciesGet() started' address cmd samba.!pdbeditexe' -P "'arg(1)'" 'DebugLevel' 1>'samba.!msg PolDesc = linein(samba.!msg) PolValue = linein(samba.!msg) ok = stream(Samba.!msg,'c','close') parse var PolDesc . ':' PolDesc parse var PolValue . ':' PolValue say strip(PolValue) say strip(PolDesc) IF options.!debug == 1 THEN say '_PoliciesGet() done' return PolValue /*:VRX _PolicySet */ _PolicySet: IF options.!debug == 1 THEN say '_PoliciesSet() started' IF options.!debug == 1 THEN say '_PoliciesSet() done' return /*:VRX _Refresh */ _Refresh: ok = VRSet("Main", 'Pointer', 'Wait' ) ok = SysSleep(0.25) call _MasterPasswdRead call _SmbpasswdRead call _SmbUserMapRead call _GroupRead call _SmbGroupsRead call _ContainerPopulate call _ContGroupsPopulate ok = VRSet("Main", 'Pointer', '' ) return /*:VRX _SambaGetProperties */ _SambaGetProperties: procedure expose options. samba. IF options.!debug == 1 THEN say '_SambaGetProperties() started' samba.!homes = "" /* Read some values from smb.conf into samba. stem */ samba.!smbusermap = VRParseFileName(translate(IniGet("username map", "global",samba.!smbconf),'\','/'),'DPNE') if samba.!smbusermap = 0 then samba.!smbusermap = "" IF options.!debug == 1 THEN say ' Samba Usermap = "'samba.!smbusermap'"' samba.!homes = VRParseFileName(translate(IniGet("path", "homes",samba.!smbconf),'\','/'),'DP') if samba.!homes = 0 then samba.!homes = "" IF options.!debug == 1 THEN say ' Samba homes = "'samba.!homes'"' samba.!profiles = translate(IniGet("path", "profiles",samba.!smbconf),'\','/') if samba.!profiles = 0 then samba.!profiles = "" IF options.!debug == 1 THEN say ' Samba profiles = "'samba.!profiles'"' samba.!netlogon = translate(IniGet("path", "netlogon",samba.!smbconf),'\','/') if samba.!netlogon = 0 then samba.!netlogon = "" IF options.!debug == 1 THEN say ' Samba netlogon = "'samba.!netlogon'"' IF options.!debug == 1 THEN say '_SambaGetProperties() done' return /*:VRX _SambaShowError */ _SambaShowError: procedure expose samba. settings. options. if stream(samba.!error,'c','query size') > 0 then do I = 0 do while lines(samba.!error) <> 0 I = I + 1 smberr.I = linein(samba.!error) end smberr.0 = I Buttons.1 = NLVGetMessage(2) Buttons.0 = 1 id = VRMessageStem( VRWindow(), "smberr.", VRGet("Main", "Caption") , "Error", "Buttons.", buttons.1, buttons.1 ) end ok = stream(Samba.!error,"c","close") ok = SysFileDelete(Samba.!error) return /*:VRX _SambaShowMsg */ _SambaShowMsg: procedure expose samba. settings. options. if stream(samba.!msg,'c','query size') > 0 then do skipWords = arg(1) skip.0 = words(skipWords) do J = 1 to skip.0 skip.J = translate(word(skipWords,J)) end I = 0 do while lines(samba.!msg) <> 0 msgline = linein(samba.!msg) SkipIt = 0 do J = 1 to skip.0 if pos(skip.J,translate(msgline)) > 0 then do skipit = 1 leave end end if \SkipIt then do I = I + 1 smbmsg.I = strip(MsgLine) end end smbmsg.0 = I if smbmsg.0 > 0 then do Buttons.1 = "OK" /* NLVGetMessage(2) */ Buttons.0 = 1 id = VRMessageStem( VRWindow(), "smbmsg.", VRGet("Main", "Caption") , "I", "Buttons.", buttons.1, buttons.1 ) end end ok = stream(Samba.!msg,"c","close") ok = SysFileDelete(Samba.!msg) return /*:VRX _SetFlag */ _SetFlag: procedure FlagVar = arg(1) FlagStatus = arg(2) FlagType = arg(3) say FlagVar if FlagStatus then do FlagVar = FlagType||translate(FlagVar,' ',FlagType) end else do FlagVar = translate(FlagVar,' ',FlagType) end FlagVar = space(FlagVar,0) say FlagVar return FlagVar /*:VRX _ShowMsg */ _ShowMsg: Buttons.1 = NLVGetMessage( 2 ) Buttons.0 = 1 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 ) IF options.!debug == 1 THEN say Msg.Text return /*:VRX _SmbGroupMembersSync */ _SmbGroupMembersSync: IF options.!debug == 1 THEN say '_SmbGroupMembersSync() started' CurGID = arg(1) if datatype(CurGID) = "NUM" then do CurNTGroupName = "" do Idx = 1 to GGID.0 /* say '"'CurGID'" --- "'GGID.Idx'"' */ if CurGID = GGID.Idx then do CurNTGroupName = NTGroupName.Idx CurGroupIdx = Idx leave end end if CurNTGroupName = "" then do say "Invalid GID "CurGID return end end else CurNTGroupName = arg(1) say samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg address cmd samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else do Z = 0 SyncedUsers = "" do while lines(samba.!msg) <> 0 Z = Z + 1 smbmsg.Z = linein(samba.!msg) parse var smbmsg.Z WorkGroup'\'User SyncedUsers = SyncedUsers||User',' end ok = stream(Samba.!msg,"c","close") smbmsg.0 = Z Gusers.CurGroupIdx = SyncedUsers end IF options.!debug == 1 THEN say '_SmbGroupMembersSync() done' return /*:VRX _SmbGroupsRead */ _SmbGroupsRead: IF options.!debug == 1 THEN say '_SmbGroupsRead() started' groupmap = TempDir'netgroupmap.txt' ok = SysFileDelete(groupmap) say ' 'samba.!netexe' groupmap list -l --debuglevel=0 >'groupmap address cmd samba.!netexe' groupmap list -l --debuglevel=0 >'groupmap gname.0 = 0 do while lines(groupmap) <> 0 gmline = linein(groupmap) if left(gmline,1) <> " " then do /* Found group */ gname.0 = gname.0 + 1 smbgname = strip(gmline) SID = substr(linein(groupmap),14) UnixGID = substr(linein(groupmap),14) Unixgroup = substr(linein(groupmap),14) GroupType = substr(linein(groupmap),14) GroupComment = substr(linein(groupmap),14) do I = 1 to Groupname.0 if GGID.I = UnixGID then do NTGroupname.I = smbgname SID.I = SID RID.I = substr(SID,lastpos('-',SID)+1) NTComment.I = GroupComment NTGroupType.I = delword(GroupType,words(GroupType)) GStatus.I = 'NOT FOUND' /* we set this FOR all NT groups - the variable is cleared, when an appriate LIBC group exists */ leave end end end end ok = stream(groupmap,'c','close') ok = SysFileDelete(groupmap) /* Now read the group list */ grouplist = TempDir'netgrouplist.txt' ok = SysFileDelete(grouplist) GroupListError = 0 say ' 'samba.!netexe' rpc group -l 'DebugLevel' 'UserCred' 1>'grouplist' 2>'samba.!error address cmd samba.!netexe' rpc group -l 'DebugLevel' 'UserCred' 1>'grouplist' 2>'samba.!error if RC <> 0 then do call _SambaShowError GroupListError = 1 end /* Read grouplist */ dummy = linein(grouplist) dummy = linein(grouplist) dummy = linein(grouplist) i = 0 do while lines(grouplist) <> 0 i = i + 1 gline.i = strip(linein(grouplist)) end ok = stream(grouplist,'c','close') ok = SysFileDelete(grouplist) gline.0 = i do i = 1 to gline.0 ngroup = strip(left(gline.i,22)) ncomment = strip(substr(gline.i,23)) do j=1 to groupname.0 if GStatus.j = "" then iterate if ngroup = strip(left(NTGroupname.j,21)) then do nox = 0 GStatus.j = "" leave end end end if gname.0 <> gline.0 & GroupListError = 0 then do Msg.Title= VRGet("Main","Caption") Msg.Type = "W" Msg.Text = NLVGetMessage(112, gline.0, gname.0) call _ShowMsg end else IF options.!debug == 1 THEN say ' Samba groups appear to be workable.' IF options.!debug == 1 THEN say '_SmbGroupsRead() done, 'gline.0' smbgroups read' return /*:VRX _SmbpasswdRead */ _SmbpasswdRead: IF options.!debug == 1 THEN say '_SmbpasswdRead() started' /* clear existing stems */ drop sline. drop sname. /* create our temporary smbpasswd file */ ok = SysFileDelete(TempDir'smbpasswd.tmp') address cmd samba.!pdbeditexe' --debuglevel=0 -L -w >'TempDir'smbpasswd.tmp' ok = SysFileDelete(samba.!smbpasswd) do while lines(TempDir'smbpasswd.tmp') <> 0 tmpline = linein(TempDir'smbpasswd.tmp') if pos(':', tmpline) = 0 then iterate if pos('corrupt', tmpline) > 0 then do parse var tmpline . 'username 'username' with uid 'uid ' is' . tmpline = username':'uid':?:?:[?'copies(' ',12)']:?:' end call lineout samba.!smbpasswd, tmpline end ok = stream(samba.!smbpasswd,'c','close') ok = stream(TempDir'smbpasswd.tmp','c','close') ok = SysFileDelete(TempDir'smbpasswd.tmp') /* Read smbpasswd */ i = 0 err = 0 cmt = 0 do while lines(samba.!smbpasswd) <> 0 i = i + 1 sline.i = strip(linein(samba.!smbpasswd)) select when left(sline.i,1) = '#' then do sname.i = '#' cmt = cmt + 1 end when pos('UNKNOWN PARAMETER', translate(sline.i)) > 0 then do sname.i = '#' err = err + 1 Msg.Title= "Broken "samba.!smbconf Msg.Text = sline.i Msg.Type = "E" call _ShowMsg end when pos(':[',translate(sline.i)) > 0 & pos(']:LCT-',translate(sline.i)) > 0 then do /* we guess a valid smbdpasswd user entry here */ parse var sline.i name':'. sname.i = translate(name) /* still something wrong - we got no name, trash this line */ if sname.i = '' then i = i - 1 end otherwise do /* if we did not find a valid line in the previous check this line is garbage, likely debug output.. */ i = i - 1 end end end sline.0 = i sname.0 = i ok = stream(samba.!smbpasswd,'c','close') /* list each line in smbpasswd */ do i=1 to sline.0 /* skip comments in smbpasswd */ if sname.i = '#' then iterate /* parse smbpasswd info */ parse var sline.i name':'uid':'lmhash':'nthash':['flags']:'lct':' flags = strip(flags) ucName = translate(name) /* find matching entry in master.passwd & confirm UIDs match */ ok = 0 bad = 0 nox = 1 do j=1 to username.0 if translate(username.j) = ucName then do nox = 0 lmhash.j = lmhash nthash.j = nthash flags.j = flags if pos('?',flags.j) > 0 then status.J = "CORRUPT SMB USER" lct.j = lct if uid.j = uid | (uid = 0 & uid.j > 65500) then ok = j else do status.j = "UID MISMATCH" IF options.!debug == 1 THEN say ' UID MISMATCH: 'uid.j' from master.passwd vs 'uid' from Samba' uid.j = uid.j end leave end end if nox then do /* No master.passwd entry found ! */ nx = 1 + username.0 username.0 = nx password.0 = nx username.nx = name uid.nx = uid gid.nx = uid password.nx = "*" loginclass.NX = '' /* dummy value */ pwchange.NX = '0' /* dummy value */ deact.NX = '0' /* dummy value */ gecos.NX = name /* not really appropriate, but better than a dummy value */ home.NX = '/nonexistent' /* dummy value */ shell.NX = '/usr/sbin/nologin' /* dummy value */ lmhash.NX = lmhash nthash.NX = nthash flags.NX = flags lct.NX = lct Status.nx = 'UNIX MISSING' /* we must fix this immediately! */ say "WARNING! Missing master.passwd record created using defaults!!!!!!!!!!!!!!!!!" call _MasterpasswdWrite call _PasswordDBRewrite end end IF options.!debug == 1 THEN say '_SmbpasswdRead() done, read 'sname.0-cmt-err' Samba users, 'cmt' comments, 'err' errors.' return /*:VRX _SmbUserMapRead */ _SmbUserMapRead: IF options.!debug == 1 THEN say '_SmbUserMapRead() started' /* Read complete smbusermap */ I = 0 if samba.!smbusermap <> "" then do do until lines(samba.!smbusermap) = 0 usermapline = strip(linein(samba.!smbusermap)) /* Skip comments */ if left(usermapline,1) = "#" then iterate if left(usermapline,1) = ";" then iterate /* parse fields into stem variables */ I = I + 1 parse var usermapline usermapname.I' = 'usernamemapto.I do J = 1 to Username.0 if translate(Username.J) = translate(Usermapname.I) then do MapTo.J = usernamemapto.I leave end end end ok = stream(samba.!smbusermap,'c','close') drop usermapline drop usermapname. drop usernamemapto. IF options.!debug == 1 THEN say '_SmbUserMapRead() done, 'I' user mappings read' end else IF options.!debug == 1 THEN say '_SmbUserMapRead() done, not installed' return /*:VRX _SmbUserMapWrite */ _SmbUserMapWrite: IF options.!debug == 1 THEN say '_SmbUserMapWrite() started' HaveMappedUser = 0 do I = 1 to MapTo.0 if MapTo.I <> "" then do HaveMappedUser = 1 leave end end if samba.!smbusermap = "" & HaveMappedUser then do Msg.Text = NLVGetMessage(110) Msg.Type = "E" call _ShowMsg IF options.!debug == 1 THEN say '_SmbUserMapWrite() done, not installed.' return end if samba.!smbusermap <> "" then do ok = VRCopyFile( samba.!smbusermap, samba.!smbusermap'.bak' ) ok = SysFileDelete(samba.!smbusermap) call lineout samba.!smbusermap, '# Created by smbusers Version 'word(VRGet("Main", "Hinttext"),2) call lineout samba.!smbusermap, '# syntax:' call lineout samba.!smbusermap, '# Samba username = Windows username' do I = 1 to MapTo.0 if MapTo.I <> "" then do call lineout samba.!smbusermap, Username.I' = 'MapTo.I end end ok = stream(samba.!smbusermap,'c','close') IF options.!debug == 1 THEN say '_SmbUserMapWrite() done' end else IF options.!debug == 1 THEN say '_SmbUserMapWrite() done, not installed.' return /*:VRX _SmbUsersList */ _SmbUsersList: userCnt = 0 /* list each line in smbpasswd */ do i=1 to sline.0 /* skip comments in smbpasswd */ if sname.i = '#' then iterate /* parse smbpasswd info */ parse var sline.i name':'uid':'.':'.':'flags':'. ucName = translate(name) /* find matching entry in master.passwd & confirm UIDs match */ ok = 0 bad = 0 do j=1 to mname.0 if mname.j = ucName then do if muid.j = uid | (uid = 0 & muid.j > 65500) then ok = j else bad = j leave end end /* if there was a match, show all info; otherwise, show smbpasswd info & an error message */ userCnt = userCnt + 1 RH = VRMethod("CN_Users","AddRecord") if ok <> 0 then do parse var mline.ok .':'.':'.':'gid':'.':'.':'.':'full':'home':'. home = _PathStrOS2(home) say left(userCnt, 4) substr(flags, 2, 4) left(name, 11) left(uid, 6), left(gid, 6) left(full, 18) left(home, 23) flags = strip(substr(flags, 2, 4)) ok = VRMethod("CN_Users","SetFieldData", RH, NrFH, UserCnt, SmbFH, flags, NameFH, Name, UIDFH, Uid, GIdFH, GID, FullNameFH, full, HomeFH, Home) end else do if bad <> 0 then error = "* UID should be '" || muid.bad || "' - use 'Change' to fix *" else error = "* Unix-user not found - use 'Change' to fix *" say left(userCnt, 4) substr(flags, 2, 4) left(name, 11) left(uid, 6), left(error, 50) flags = strip(substr(flags, 2, 4)) ok = VRMethod("CN_Users","SetFieldData", RH, SCommentFH, error) ok = VRMethod("CN_Users","SetFieldData", RH, NrFH, UserCnt, SmbFH, flags, NameFH, Name, UIDFH, Uid ) end end if userCnt = 0 then say " * No Samba users have been defined - use the 'Add' command * " return /*:VRX _useraddsmb */ _useraddsmb: IF options.!debug == 1 THEN say '_UserAddSmb() started' select when VRGet("CB_MachineAccount","Set") then do say ' 'samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -m' address cmd samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -m 2>'samba.!error' 1>'samba.!msg smbpasswdrc = rc if rc <> 0 then call _SambaShowError else call _SambaShowMsg end when VRGet("CB_NoPassword","Set") then do say ' 'samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -n' address cmd samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -n 2>'samba.!error' 1>'samba.!msg smbpasswdrc = rc if rc <> 0 then call _SambaShowError else call _SambaShowMsg end otherwise do pwdfile = TempDir'newpwd' call lineout pwdfile, VRGet("EF_Password","value") call lineout pwdfile, VRGet("EF_Password","value") ok = stream(pwdfile,"c","close") say ' 'samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -s <'pwdfile' 2>'samba.!error address cmd samba.!smbpasswdexe' -a 'VRGet("EF_Username","Value")' -s <'pwdfile' 2>'samba.!error' 1>'samba.!msg smbpasswdrc = rc if rc <> 0 then call _SambaShowError else call _SambaShowMsg if swatauth & VRGet("CB_Swat_Allowed","set") then do if VRFileExists(swatusers) then cFlag = ""; else cFlag="c" say ' 'samba.!htpasswdexe' -b "'swatusers'" 'VRGet("EF_Username","Value")' 'copies("*",length(VRGet("EF_Password","value"))) address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" 'VRGet("EF_Username","Value")' 'VRGet("EF_Password","value")' 2>'samba.!error' 1>'samba.!msg if rc <> 0 then call _SambaShowError else call _SambaShowMsg end ok = SysFileDelete(pwdfile) end end IF options.!debug == 1 THEN say '_UserAddSmb() done' return /*:VRX _UserIsValid */ _UserIsValid: procedure expose username. User = arg(1) HaveValidUser = 0 do I = 1 to username.0 if translate(username.I) = translate(User) then do HaveValiduser = 1 leave end end return HaveValidUser /*:VRX _UserPropertiesGet */ _UserPropertiesGet: IF options.!debug == 1 THEN say '_UserPropertiesGet() started' CurUser = arg(1) /* "up" is an abbreviation for UserProperties in here */ UserProperties = TempDir'UserProperties.txt' ok = SysFileDelete(UserProperties) IF options.!debug == 1 THEN say ' 'samba.!pdbeditexe' 'CurUser' -L -v 'debuglevel address cmd samba.!pdbeditexe' 'CurUser' -L -v 'DebugLevel' >'UserProperties /* Read user properties */ i = 0 do while lines(UserProperties) <> 0 i = i + 1 upline.i = strip(linein(UserProperties)) end ok = stream(UserProperties,'c','close') ok = SysFileDelete(UserProperties) upline.0 = i ok = VRSet("CN_UserProperties","Painting", 0 ) ok = VRMethod("CN_UserProperties","RemoveRecord","ALL") do i = 1 to upline.0 parse var upline.i uptype.i ':' upvalue.i uptype.i = strip(uptype.i) upvalue.i = strip(upvalue.i) CurType = translate(uptype.i) /* say CurType */ select when CurType = "DOMAIN" then upCommand.i = "--domain=" when CurType = "PROFILE PATH" then upCommand.i = "--profile=" when CurType = "ACCOUNT DESC" then upCommand.i = "--account-desc=" when CurType = "FULL NAME" then upCommand.i = "--fullname=" when CurType = "LOGON SCRIPT" then upCommand.i = "--script=" when CurType = "HOME DIRECTORY" then upCommand.i = "--homedir=" when CurType = "HOMEDIR DRIVE" then upCommand.i = "--drive=" /* when CurType = "ACCOUNT FLAGS" then upCommand.i = '-c "[NDHLX]"' */ when CurType = "PRIMARY GROUP SID" then do upCommand.i = "" if Settings.!SyncPrimGID = 1 & \(translate(Username.CurUserNr) = "GUEST"|translate(Username.CurUserNr) = "NOBODY") then do NewPrimGID = substr(upvalue.i,lastpos('-',upvalue.i)+1,) IF options.!debug == 1 THEN say " NewPrimGID = "NewPrimGID If GID.CurUserNr <> NewPrimGID then do GID.CurUserNr = NewPrimGID IF options.!debug == 1 THEN say " Synced Primary GID!" SyncedPrimGID = 1 end end end otherwise upCommand.i = "" end uprh.i = VRMethod("CN_UserProperties","AddRecord") ok = VRMethod("CN_UserProperties","SetFieldData", uprh.i, upNrFH, i, upTypeFH, uptype.i, upValueFH, upValue.i, upCommandFH, upCommand.i ) NotHaveCommand = (upCommand.i = "") ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "ReadOnly", NotHaveCommand) if VRGet("CB_EditableFieldsOnly","Set") then ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "Visible", \NotHaveCommand) select when CurType = "ACCOUNT FLAGS" then do /* ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "Visible", 0) */ parse var upvalue.I '['CurFlags']' if pos("U", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Regular user account") if pos("T", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Temporary duplicate of other account") if pos("M", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "MNS logon user account") if pos("W", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Workstation Trust Account") if pos("S", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Server Trust Account") if pos("I", CurFlags) > 0 then ok = VRSet("EF_AccountType","Value", "Domain Trust Account") ok = VRSet("CB_upNoPassword", "Set", (pos("N",CurFlags) > 0)) call CB_upNoPassword_Click ok = VRSet("CB_upPassword_doesnt_expire", "Set", (pos("X",CurFlags) > 0)) ok = VRSet("CB_upDeactivated", "Set", (pos("D",CurFlags) > 0)) end when right(CurType,8) = "USERNAME" then do ok = VRMethod("CN_UserProperties","SetRecordAttr", uprh.i, "Visible", 0) ok = VRSet("UserProperties", "caption", NLVGetMessage(120)' "'Username.CurUserNr'"') end otherwise nop end end if SwatAuth then do ok = VRSet("CB_upSWAT_Allowed","Enabled",0) ok = VRSet("CB_upSWAT_Allowed","set",0) swatchanged = 0 if VRFileExists(swatusers) then do do until lines(swatusers) = 0 swatline = linein(swatusers) parse var swatline curswatuser ':' curswatpw if curswatuser = CurUser then do ok = VRSet("CB_upSWAT_Allowed","set",1) leave end end ok = stream(swatusers,'c','close') end end ok = VRSet("CN_UserProperties","Painting", 1 ) IF options.!debug == 1 THEN say '_UserPropertiesGet() done' return /*:VRX _UserRecWriteBackToStems */ _UserRecWriteBackToStems: IF options.!debug == 1 THEN say '_UserRecWriteBackToStems() started' if VRMethod( "CN_Users", "ValidateRecord", RH ) then do Cur = VRMethod("CN_Users","GetFieldData", RH, NrFH) Username.Cur = VRMethod("CN_Users","GetFieldData", RH, UsernameFH) UID.Cur = VRMethod("CN_Users","GetFieldData", RH, UIDFH) GID.Cur = VRMethod("CN_Users","GetFieldData", RH, GIDFH) GECOS.Cur = VRMethod("CN_Users","GetFieldData", RH, GECOSFH) Home.Cur = _PathStrkLIBC(VRMethod("CN_Users","GetFieldData", RH, HomeFH)) Shell.Cur = VRMethod("CN_Users","GetFieldData", RH, ShellFH) MapTo.Cur = VRMethod("CN_Users","GetFieldData", RH, MapToFH) if Settings.!SyncFullName = 1 & flags.Cur <> "" then do say " Sync is enabled, therefore we must save now!" call PB_Save_Click say samba.!pdbeditexe' --user='Username.Cur' --modify --fullname="'GECOS.Cur'" 'DebugLevel' 1>NUL 2>'samba.!error address cmd samba.!pdbeditexe' --user='Username.Cur' --modify --fullname="'GECOS.Cur'" 'DebugLevel' 1>NUL 2>'samba.!error if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */ end /* These are not editable/visible xpwFH, password.i,xlcFH,LoginClass.I,xcpwFH, pwchange.I,xDeactFH, deact.I, Status.I ) */ /* smbpasswd fields */ /* we do not allow editing these FLagsFH, flags.I, LMHashFH, LMHash.I,NTHashFH, NTHash.I, LCTFH, LCT.I) */ end else say RH' is no valid record!' IF options.!debug == 1 THEN say '_UserRecWriteBackToStems() done' return /*:VRX About_Close */ About_Close: call About_Fini return /*:VRX About_Create */ About_Create: call About_Init ok = VRSet("About","Caption", NLVGetMessage(127)) ok = VRSet("PB_AboutOK","Caption", NLVGetMessage(2)) SambaTeam.0 = 9 SambaTeam.1 = 'Silvan Scherrer' SambaTeam.2 = 'Herwig Bauernfeind' SambaTeam.3 = 'Vitali Pelenyov' SambaTeam.4 = 'Paul Smedley' SambaTeam.5 = 'Yuri Dario' SambaTeam.6 = 'Alex Taylor' SambaTeam.7 = 'Nikolay Kolosov' SambaTeam.8 = 'All the Samba people' SambaTeam.9 = 'All the netlabs people' ok = VRSet("About","Font", VRGet("Page_4","Font")) ok = VRMethod("LB_SambaTeam","AddStringList", "SambaTeam." ) ok = VRSet("DT_SambaTeam","Caption", NLVGetMessage(129)) ok = VRSet("MLE_Version","Value", NLVGetMessage(1)||'0D0A'x||VRGet("Main", "Hinttext")||'0D0A'x||'0D0A'x||SambaVer) return /*:VRX About_Fini */ About_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX About_Init */ About_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Activate */ Activate: parse arg Nr call PushbackAll CurrentPageNr = Nr /* ok = VRSet("PB_"Nr,"Font","9.WarpSans Bold") */ ok = VRSet("TAB_"Nr,"Top", TabTop-8) ok = VRSet("TAB_"Nr,"Left",TabWidth*(Nr-1)+PageLeft) ok = VRSet("TAB_"Nr,"PicturePath", "#1"||Nr||";#1"||Nr) ok = VRset("DT_PageName", "Caption", VRGet("TAB_"Nr, "UserData")) ok = VRSet("Page_"Nr,"Visible", 1) select when Nr = 1 then ok = VRSet("IPB_paper","PicturePath","#4;#4") when Nr = Pages then ok = VRSet("IPB_paper","PicturePath","#6;#6") otherwise ok = VRSet("IPB_paper","PicturePath","#5;#5") end return /*:VRX AddGroup_Close */ AddGroup_Close: call AddGroup_Fini return /*:VRX AddGroup_Create */ AddGroup_Create: call AddGroup_Init CALL NLVSetText 'AddGroup', 'Caption', 70 CALL NLVSetText 'PB_GroupAddOK', 'Caption', 2 CALL NLVSetText 'PB_GroupAddCancel', 'Caption', 3 CALL NLVSetText 'DT_GroupName', 'Caption', 71 CALL NLVSetText 'DT_Comment', 'Caption', 72 CALL NLVSetText 'CB_UnixGroupOnly', 'Caption', 73 CALL NLVSetText 'CB_AutomaticGGID', 'Caption', 74 UnixGroupOnly = 0 return /*:VRX AddGroup_Fini */ AddGroup_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX AddGroup_Init */ AddGroup_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX AddUser_Close */ AddUser_Close: call AddUser_Fini return /*:VRX AddUser_Create */ AddUser_Create: call AddUser_Init CALL NLVSetText 'AddUser', 'Caption', 40 Msg.Title = VRGet("AddUser","Caption") CALL NLVSetText 'DT_Username', 'Caption', 41 CALL NLVSetText 'DT_GECOS', 'Caption', 42 CALL NLVSetText 'DT_Password_Repeat', 'Caption', 43 CALL NLVSetText 'DT_GID', 'Caption', 44 CALL NLVSetText 'DT_Home', 'Caption', 140 CALL NLVSetText 'DT_Description', 'Caption', 52 CALL NLVSetText 'CB_Must_change_password', 'Caption', 46 CALL NLVSetText 'CB_Cannot_change_password','Caption', 47 CALL NLVSetText 'CB_Password_doesnt_expire', 'Caption', 48 CALL NLVSetText 'CB_Deactivated', 'Caption', 49 CALL NLVSetText 'CB_NoHome', 'Caption', 9 CALL NLVSetText 'PB_AddUserOK', 'Caption', 2 CALL NLVSetText 'PB_AddUserCancel', 'Caption', 3 CALL NLVSetText 'CB_UnixUserOnly', 'Caption', 18 CALL NLVSetText 'CB_MachineAccount', 'Caption', 19 CALL NLVSetText 'CB_NoPassword', 'Caption', 20 CALL NLVSetText 'DT_Password', 'Caption', 33 CALL NLVSetText 'CB_SWAT_Allowed', 'Caption', 35 ok = VRSet("CB_SWAT_Allowed","enabled",Swatauth) MinPWLength = _PolicyGet("min password length") if IsUnixUser then do ok = VRSet("EF_Username","value", Username.SelNr) call EF_Username_LostFocus ok = VRMethod("EF_GECOS","SetFocus") end else do NextUID = _GetNextUID() ok = VRSet("DT_UID","Caption", "UID: "NextUID) ok = VRSet("DDCB_GID","Value", NextUID) do I = 1 to GGID.0 if GGID.I = "513" then do ok = VRSet("DDCB_GID","Value", "513") leave end end ok = VRMethod( "DDCB_GID", "Reset") ok = VRMethod( "DDCB_GID", "AddString", NextUID) ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.") ok = VRSet("EF_Home", "Value", Samba.!Homes'\') call EF_Home_Change end SecondStage = 0 return /*:VRX AddUser_Fini */ AddUser_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX AddUser_Init */ AddUser_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX CB_AutomaticGGID_Click */ CB_AutomaticGGID_Click: ok = VRSet("EF_GGID","Enabled", \VRget("CB_AutomaticGGID","Set")) if \VRget("CB_AutomaticGGID","Set") then ok = VRSet("EF_GGID","BackColor","") else ok = VRSet("EF_GGID","BackColor","PaleGray") return /*:VRX CB_Cannot_change_password_Click */ CB_Cannot_change_password_Click: SecondStage = (SecondStage | VRGet("CB_Cannot_change_password","set")) return /*:VRX CB_Deactivated_Click */ CB_Deactivated_Click: SecondStage = (SecondStage | VRGet("CB_Deactivated","set")) return /*:VRX CB_Debug_Click */ CB_Debug_Click: options.!Debug = VRGet("CB_Debug","set") if options.!Debug then ok = VRREdirectStdIO("ON") else ok = VRREdirectStdIO("OFF") return /*:VRX CB_EditableFieldsOnly_Click */ CB_EditableFieldsOnly_Click: call _UserPropertiesGet Username.CurUserNr return /*:VRX CB_FixErrors_Click */ CB_FixErrors_Click: settings.!FixErrors = VRGet("CB_FixErrors","set") return /*:VRX CB_MachineAccount_Click */ CB_MachineAccount_Click: IF options.!debug == 1 THEN say 'CB_MachineAccount_Click started' if right(VRGet("EF_Username","Value"),1) = "$" then do if VRGet("EF_Username","Value") <> translate(VRGet("EF_Username","Value")) then ok = VRSet("EF_Username","Value",translate(VRGet("EF_Username","Value"))) ok = VRset("CB_UnixUserOnly","set", 0) ok = VRset("CB_MachineAccount","set", 1) ok = VRSet("CB_NoPassword","set", 0) ok = VRSet("CB_NoPassword","Enabled", 0) ok = VRSet("EF_Password","BackColor", "PaleGray") ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray") ok = VRSet("EF_Password","Enabled", 0) ok = VRSet("EF_Password_Repeat","Enabled", 0) ok = VRSet("CB_Must_Change_Password","Enabled", 0) ok = VRSet("CB_Cannot_change_password","Enabled", 0) ok = VRSet("CB_Password_doesnt_expire","Enabled", 0) end else do ok = VRset("CB_MachineAccount","set", 0) ok = VRSet("CB_NoPassword","Enabled", 1) call CB_NoPassword_Click end IF options.!debug == 1 THEN say 'CB_MachineAccount_Click done' return /*:VRX CB_Must_change_password_Click */ CB_Must_change_password_Click: SecondStage = (SecondStage | VRGet("CB_Must_change_password","set")) if VRGet("CB_Must_Change_Password","set") then do ok = VRSet("CB_Cannot_change_password","Set", 0) ok = VRSet("CB_Password_doesnt_expire","Set", 0) ok = VRSet("CB_Cannot_change_password","Enabled", 0) ok = VRSet("CB_Password_doesnt_expire","Enabled", 0) end else do ok = VRSet("CB_Cannot_change_password","Enabled", 1) ok = VRSet("CB_Password_doesnt_expire","Enabled", 1) end return /*:VRX CB_NoHome_Click */ CB_NoHome_Click: ok = VRSet("EF_Home","Enabled",\VRGet("CB_NoHome","set")) ok = VRset("PB_CreateHome","Enabled",\VRGet("CB_NoHome","set")) ok = VRSet("PB_ChooseHome","Enabled",\VRGet("CB_NoHome","set")) if VRGet("CB_NoHome","set") then ok = VRSet("EF_HOME","Value", "\nonexistent") return /*:VRX CB_NoPassword_Click */ CB_NoPassword_Click: if VRGet("CB_NoPassword","set") then do ok = VRSet("EF_Password","BackColor", "PaleGray") ok = VRSet("EF_Password_Repeat","BackColor", "PaleGray") ok = VRSet("EF_Password","Enabled", 0) ok = VRSet("EF_Password_Repeat","Enabled", 0) ok = VRSet("CB_Must_Change_Password","Enabled", 0) ok = VRSet("CB_Cannot_change_password","Enabled", 0) ok = VRSet("CB_Password_doesnt_expire","Enabled", 0) ok = VRSet("CB_SWAT_Allowed","Enabled", 0) end else do ok = VRSet("EF_Password","BackColor", "") ok = VRSet("EF_Password_Repeat","BackColor", "") ok = VRSet("EF_Password","Enabled", 1) ok = VRSet("EF_Password_Repeat","Enabled", 1) ok = VRSet("CB_Must_Change_Password","Enabled", 1) ok = VRSet("CB_Cannot_change_password","Enabled", 1) ok = VRSet("CB_Password_doesnt_expire","Enabled", 1) ok = VRSet("CB_SWAT_Allowed","Enabled", 1) end return /*:VRX CB_Password_doesnt_expire_Click */ CB_Password_doesnt_expire_Click: SecondStage = (SecondStage | VRGet("CB_Password_doesnt_expire","set")) return /*:VRX CB_SmbGroupsOnly_Click */ CB_SmbGroupsOnly_Click: settings.!SmbGroupsOnly = VRGet("CB_SmbGroupsOnly","Set") call _ContGroupsPopulate return /*:VRX CB_SmbOnly_Click */ CB_SmbOnly_Click: settings.!SmbOnly = VRGet("CB_SmbOnly","Set") call _ContainerPopulate return /*:VRX CB_SWAT_Allowed_Click */ CB_SWAT_Allowed_Click: call CB_MachineAccount_Click return /*:VRX CB_SyncFullName_Click */ CB_SyncFullName_Click: settings.!SyncFullName = VRGet("CB_SyncFullName","set") return /*:VRX CB_SyncPrimGID_Click */ CB_SyncPrimGID_Click: settings.!SyncPrimGID = VRGet("CB_SyncPrimGID","set") return /*:VRX CB_UnixGroupOnly_Click */ CB_UnixGroupOnly_Click: UnixGroupOnly = VRGet("CB_UnixGroupOnly","set") ok = VRSet("EF_Comment","Enabled", \VRget("CB_UnixGroupOnly","Set")) if \VRget("CB_UnixGroupOnly","Set") then ok = VRSet("EF_Comment","BackColor","") else ok = VRSet("EF_Comment","BackColor","PaleGray") return /*:VRX CB_UnixUserOnly_Click */ CB_UnixUserOnly_Click: if VRGet("CB_UnixUserOnly","set") then do ok = VRSet("CB_NoPassword","set",1) call CB_NoPassword_Click ok = VRSet("EF_Description", "BackColor", "PaleGray") ok = VRSet("EF_Description", "Enabled", 0) end else do ok = VRSet("EF_Description", "BackColor", "") ok = VRSet("EF_Description", "Enabled", 1) ok = VRSet("CB_NoPassword","set",0) call CB_NoPassword_Click end return /*:VRX CB_upCannot_change_password_Click */ CB_upCannot_change_password_Click: return /*:VRX CB_upDeactivated_Click */ CB_upDeactivated_Click: CurFlags = _SetFlag(CurFlags, VRGet("CB_upDeactivated","set"), 'D') return /*:VRX CB_upMust_change_password_Click */ CB_upMust_change_password_Click: return /*:VRX CB_upNoPassword_Click */ CB_upNoPassword_Click: CurFlags = _SetFlag(CurFlags, VRGet("CB_upNoPassword","set"), 'N') if VRGet("CB_upNoPassword","set") then do ok = VRSet("EF_upPassword","value","") ok = VRSet("EF_upPassword_Repeat","value","") ok = VRSet("DT_upPassword","Enabled",0) ok = VRSet("DT_upPassword_Repeat","Enabled",0) ok = VRSet("EF_upPassword","Enabled",0) ok = VRSet("EF_upPassword_Repeat","Enabled",0) ok = VRSet("EF_upPassword","BackColor", "PaleGray") ok = VRSet("EF_upPassword_Repeat","BackColor", "PaleGray") end else do ok = VRSet("DT_upPassword","Enabled",1) ok = VRSet("DT_upPassword_Repeat","Enabled",1) ok = VRSet("EF_upPassword","Enabled",1) ok = VRSet("EF_upPassword_Repeat","Enabled",1) ok = VRSet("EF_upPassword","BackColor", "") ok = VRSet("EF_upPassword_Repeat","BackColor", "") end return /*:VRX CB_upPassword_doesnt_expire_Click */ CB_upPassword_doesnt_expire_Click: CurFlags = _SetFlag(CurFlags, VRGet("CB_upPassword_doesnt_expire","set"), 'X') return /*:VRX CB_upSWAT_Allowed_Click */ CB_upSWAT_Allowed_Click: swatchanged = 1 return /*:VRX CB_WriteMasterPwd_Click */ CB_WriteMasterPwd_Click: settings.!WriteMasterPwd = VRGet("CB_WriteMasterPwd","set") return /*:VRX CN_Groups_ContextMenu */ CN_Groups_ContextMenu: if VRInfo("Top") < 1325 & VRGet("CN_Groups", "View") = "Detail" then call _ColumnsMenu "CN_Groups" else ok = VRMethod( "Contextmenu_Group", "Popup", , , "", "PositionOnItem" ) return /*:VRX CN_Groups_DoubleClick */ CN_Groups_DoubleClick: call Contextmenu_GroupMembers_Click return /*:VRX CN_Groups_EndEdit */ CN_Groups_EndEdit: call beep 880, 20 GRH = VRInfo("Record") /* write back all editable field to the stems */ call _GroupRecWritebackToStems return /*:VRX CN_UserProperties_BeginEdit */ CN_UserProperties_BeginEdit: drop NewupValue drop OldupValue upRH = VRInfo("Record") OldupValue = VRMethod("CN_UserProperties","GetFieldData", upRH, upValueFH) say OldupValue return /*:VRX CN_UserProperties_EndEdit */ CN_UserProperties_EndEdit: upRH = VRInfo("Record") NewupValue = VRMethod("CN_UserProperties","GetFieldData", upRH, upValueFH) say NewupValue if OldUpValue <> NewupValue then do newcommand = newcommand||' 'VRMethod("CN_UserProperties","GetFieldData", upRH,upCommandFH)||'"'NewupValue'"' say "New command: "newcommand end return /*:VRX CN_Users_Click */ CN_Users_Click: if VRInfo("Top") < 1325 & VRGet("CN_Users", "View") = "Detail" then return return /*:VRX CN_Users_ContextMenu */ CN_Users_ContextMenu: say VRInfo("top") if VRInfo("Top") < 1325 & VRGet("CN_users", "View") = "Detail" then call _ColumnsMenu "CN_users" else do RH = VRInfo("Record") if RH <> "" then do CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH) ok = VRset("Contextmenu_UserProperties", "Enabled", (CurFlags <> "")) ok = VRMethod( "Contextmenu_user", "Popup", , , "", "PositionOnItem" ) end end return /*:VRX CN_Users_DoubleClick */ CN_Users_DoubleClick: if VRInfo("Top") < 340 & VRGet("CN_Users", "View") = "Detail" then return say 'CN_Users_DoubleClick() started' RH = VRInfo("Record") CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH) if CurFlags <> "" then window = VRLoadSecondary( "UserProperties", "W" ) say 'CN_Users_DoubleClick() done' return /*:VRX CN_Users_EndEdit */ CN_Users_EndEdit: if VRInfo("Top") < 340 & VRGet("CN_Users", "View") = "Detail" then do say VRInfo("Object") return end call beep 880, 20 RH = VRInfo("Record") say "RH="RH /* write back all editable field to the stems */ call _UserRecWritebackToStems return /*:VRX Columns_01_Click */ Columns_01_Click: call _ColumnShow return /*:VRX Columns_02_Click */ Columns_02_Click: call _ColumnShow return /*:VRX Columns_03_Click */ Columns_03_Click: call _ColumnShow return /*:VRX Columns_04_Click */ Columns_04_Click: call _ColumnShow return /*:VRX Columns_05_Click */ Columns_05_Click: call _ColumnShow return /*:VRX Columns_06_Click */ Columns_06_Click: call _ColumnShow return /*:VRX Columns_07_Click */ Columns_07_Click: call _ColumnShow return /*:VRX Columns_08_Click */ Columns_08_Click: call _ColumnShow return /*:VRX Columns_09_Click */ Columns_09_Click: call _ColumnShow return /*:VRX Columns_10_Click */ Columns_10_Click: call _ColumnShow return /*:VRX Columns_11_Click */ Columns_11_Click: call _ColumnShow return /*:VRX Columns_12_Click */ Columns_12_Click: call _ColumnShow return /*:VRX Columns_13_Click */ Columns_13_Click: call _ColumnShow return /*:VRX Columns_14_Click */ Columns_14_Click: call _ColumnShow return /*:VRX Columns_15_Click */ Columns_15_Click: call _ColumnShow return /*:VRX Columns_16_Click */ Columns_16_Click: call _ColumnShow return /*:VRX Columns_17_Click */ Columns_17_Click: call _ColumnShow return /*:VRX Contextmenu_GroupAdd_Click */ Contextmenu_GroupAdd_Click: window = VRLoadSecondary( "AddGroup", "W" ) return /*:VRX Contextmenu_GroupDel_Click */ Contextmenu_GroupDel_Click: ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." ) if SelGRH.0 = 0 then return SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH) say 'Selected Group Nr = ' SelGNr Msg.Title = NLVGetMessage(75) Msg.Type = "Q" Msg.Text = NLVGetMessage(76,Groupname.SelGNr,NTGroupname.SelGNr,GGID.SelGNr) ok = _MsgYesNo() if ok = 1 then do if RID.SelGNr <> "" then do say samba.!netexe' rpc group delete "'NTGroupname.SelGNr'" 'UserCred address cmd samba.!netexe' rpc group delete "'NTGroupname.SelGNr'" 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then do call _SambaShowError return end else call _SambaShowMsg end do I = 1 to Username.0 if GID.I = GGID.SelGNr then do GID.I = UID.I ok = VRMethod("CN_users","SetFieldData", RH.I, GIDFH, GID.I) end end ok = SysStemDelete("groupname.", SelGNr) ok = SysStemDelete("gpasswd.", SelGNr) ok = SysStemDelete("ggid.", SelGNr) ok = SysStemDelete("gusers.", SelGNr) ok = SysStemDelete("NTGroupname.",SelGNr) ok = SysStemDelete("RID.", SelGNr) ok = SysStemDelete("Gstatus.", SelGNr) ok = VRMethod("CN_Groups", "RemoveRecord", SelGRH.1) call PB_Save_Click call PB_Refresh_Click end return /*:VRX Contextmenu_GroupDetailView_Click */ Contextmenu_GroupDetailView_Click: ok = VRSet("CN_Groups", "View", "Detail") return /*:VRX Contextmenu_GroupMap_Click */ Contextmenu_GroupMap_Click: ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." ) if SelGRH.0 = 0 then return SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH) say 'Selected Group Nr = ' SelGNr if RID.SelGnr <> "" then do Msg.Type = "E" Msg.Title = NLVGetMessage(91) Msg.Text = NLVGetMessage(114,Groupname.SelGNr) call _showMsg return end window = VRLoadSecondary( "MapGroup", "W" ) return /*:VRX Contextmenu_GroupMembers_Click */ Contextmenu_GroupMembers_Click: ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." ) if SelGRH.0 = 0 then return SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH) say 'Selected Group Nr = ' SelGNr CurNTGroupName = NTGroupname.SelGNr window = VRLoadSecondary( "Group_Members", "W" ) return /*:VRX Contextmenu_GroupRebuildScript_Click */ Contextmenu_GroupRebuildScript_Click: RebuildScript = VRFileDialog( VRWindow(), NLVGetMessage( 99 ), "Save", samba.!bin"\RebuildGroups.CMD", , , ) if RebuildScript = "" then return ok = SysFileDelete(RebuildScript) call lineout RebuildScript,'@echo off' call lineout RebuildScript, 'rem Created by SmbUsers 'VRGet("Main","Hinttext") do I = 1 to groupname.0 if RID.I <> "" then do select when left(translate(NTGroupType.I),4) = "WELL" then Gtype = 'builtin' when left(translate(NTGroupType.I),4) = "LOCA" then Gtype = 'local' otherwise Gtype = 'domain' end call lineout RebuildScript, 'net groupmap add rid='RID.I' ntgroup="'NTGroupName.I'" unixgroup="'Groupname.I'" type='GType' comment="'NTComment.I'"' end end call lineout RebuildScript, 'echo Done.' Msg.Title = NLVGetMessage( 98 ) Msg.Type = "I" Msg.Text = NLVGetMessage( 108, RebuildScript ) call _ShowMsg return /*:VRX Contextmenu_GroupSymbolView_Click */ Contextmenu_GroupSymbolView_Click: ok = VRSet("CN_Groups", "View", "Icon") return /*:VRX Contextmenu_GroupUnmap_Click */ Contextmenu_GroupUnmap_Click: ok = VRMethod( "CN_Groups", "GetRecordList", "Selected", "SelGRH." ) if SelGRH.0 = 0 then return SelGNr = VRMethod("CN_Groups", "GetFieldData", SelGRH.1, GNrFH) say 'Selected Group Nr = ' SelGNr if RID.SelGnr = "" then do Msg.Type = "E" Msg.Title = NLVGetMessage( 95 ) Msg.Text = NLVGetMessage(96, Groupname.SelGNr ) call _showMsg return end Msg.Type = "E" Msg.Title = NLVGetMessage( 95 ) Msg.Text = NLVGetMessage( 97, NTGroupname.SelGNr, GroupName.SelGNr ) ok = _MsgYesNo() if ok = 1 then do blGusers = translate(Gusers.SelGnr,' ',',') do I = 1 to words(blGusers) address cmd samba.!netexe' rpc group delmem "'NTGroupname.SelGNr'" 'word(BlGusers,I)' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else call _SambaShowMsg say samba.!netexe' RC = 'RC end say samba.!netexe' groupmap delete ntgroup="'NTGroupname.SelGNr'" 'debuglevel address cmd samba.!netexe' groupmap delete ntgroup="'NTGroupname.SelGNr'" 'debuglevel' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else call _SambaShowMsg call PB_Refresh_Click end return /*:VRX Contextmenu_GroupWellKnown_Click */ Contextmenu_GroupWellKnown_Click: if Groupname.0 <> 0 then do Msg.Title = NLVGetMessage( 92 ) Msg.Text = NLVGetMessage( 93 ) Msg.Type = "W" call _ShowMsg return end call _kLIBCGroupADD "admins", 512 call _kLIBCGroupADD "users", 513 call _kLIBCGroupADD "guests", 514 call _kLIBCGroupADD "machines", 515 call _kLIBCGroupADD "dc", 516 call _kLIBCGroupADD "certadmin", 517 call _kLIBCGroupADD "schemeadmin", 518 call _kLIBCGroupADD "entadmin", 519 call _kLIBCGroupADD "poladmin", 520 call PB_Save_Click 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError 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 if RC <> 0 then call _SambaShowError Msg.Title = NLVGetMessage( 92 ) Msg.Type = "I" Msg.Text = NLVGetMessage( 94 ) call _ShowMsg call PB_Refresh_Click return /*:VRX Contextmenu_UserAdd_Click */ Contextmenu_UserAdd_Click: IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() started' ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." ) if SelRH.0 = 0 then do IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() done, aborted' return end SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH) /* IF options.!debug == 1 THEN say ' Flags.SelNr = "'flags.SelNr'"' */ if flags.SelNr = "" then IsUnixUser = 1 else IsUnixUser = 0 IF options.!debug == 1 THEN say ' Selected User Nr = 'SelNr IF options.!debug == 1 THEN say ' Is kLIBC User only? 'IsUnixUser window = VRLoadSecondary( "AddUser", "W" ) IF options.!debug == 1 THEN say 'Contextmenu_UserAdd_Click() done' return /*:VRX Contextmenu_UserDel_Click */ Contextmenu_UserDel_Click: IF options.!debug == 1 THEN say 'Contextmenu_UserDel_Click() started' ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." ) if SelRH.0 = 0 then return SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH) IF options.!debug == 1 THEN say ' Selected User Nr = 'SelNr Msg.Title = NLVGetMessage(50) Msg.Text = NLVGetMessage(51, '"'Username.SelNr'" (UID: 'UID.SelNr')') ok = _MsgYesNo() if ok = 1 then do if flags.SelNr <> "" then do say ' 'samba.!netexe' rpc user delete "'Username.SelNr'" 'UserCred' 'Debuglevel' 2>'samba.!error' 1>'samba.!msg address cmd samba.!netexe' rpc user delete "'Username.SelNr'" 'UserCred' 'Debuglevel' 2>'samba.!error' 1>'samba.!msg if rc <> 0 then call _SambaShowError; else call _SambaShowMsg if swatauth then do say ' 'samba.!htpasswdexe' -D "'swatusers'" 'Username.SelNr address cmd samba.!htpasswdexe' -D "'swatusers'" 'Username.SelNr' 2>'samba.!error' 1>'samba.!msg if rc <> 0 then call _SambaShowError else call _SambaShowMsg end end else do /* kLIBC user only */ ExUserName = Username.SelNr ExUID = UID.SelNr ExGID = GID.SelNr ok = SysStemDelete("username.",SelNr) ok = SysStemDelete("password.",SelNr) ok = SysStemDelete("uid.",SelNr) ok = SysStemDelete("gid.",SelNr) ok = SysStemDelete("loginclass.",SelNr) ok = SysStemDelete("pwchange.",SelNr) ok = SysStemDelete("deact.",SelNr) ok = SysStemDelete("gecos.",SelNr) ok = SysStemDelete("home.",SelNr) ok = SysStemDelete("shell.",SelNr) ok = SysStemDelete("status.",SelNr) ok = SysStemDelete("lmhash.",SelNr) ok = SysStemDelete("nthash.",SelNr) ok = SysStemDelete("flags.",SelNr) ok = SysStemDelete("lct.",SelNr) do I = 1 to gusers.0 blGUsers = translate(Gusers.I,' ',',') UPos = wordpos(translate(ExUserName),translate(blGusers)) if Upos > 0 then do blGUsers = delword(BlGusers,UPos,1) Gusers.I = translate(blGusers,',',' ') end end call PB_Save_Click Msg.Title = NLVGetMessage(50) Msg.Text = NLVGetMessage(53, '"'ExUsername'"' ) Msg.Type = 'I' call _ShowMsg end call PB_Refresh_Click end IF options.!debug == 1 THEN say 'Contextmenu_UserDel_Click() done' return /*:VRX Contextmenu_UserDetailView_Click */ Contextmenu_UserDetailView_Click: ok = VRSet("CN_users", "View", "Detail") return /*:VRX Contextmenu_UserJoinGroup_Click */ Contextmenu_UserJoinGroup_Click: ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." ) if SelRH.0 = 0 then return SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH) say 'Selected User Nr = ' SelNr window = VRLoadSecondary( "Join_Group", "W" ) return /*:VRX Contextmenu_UserLeaveGroup_Click */ Contextmenu_UserLeaveGroup_Click: ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." ) if SelRH.0 = 0 then return SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH) say 'Selected User Nr = ' SelNr window = VRLoadSecondary( "Leave_Group", "W" ) return /*:VRX Contextmenu_UserProperties_Click */ Contextmenu_UserProperties_Click: window = VRLoadSecondary( "UserProperties", "W" ) return /*:VRX Contextmenu_UserSymbolView_Click */ Contextmenu_UserSymbolView_Click: ok = VRSet("CN_users", "View", "Icon") return /*:VRX DDCB_GID_Change */ DDCB_GID_Change: ok = VRSet("DT_PrimaryGroupName","Caption","UID") if VRGet("DDCB_GID","Value") = NextUID then return do x = 1 to groupname.0 if VRGet("DDCB_GID","Value") = GGID.x then do ok = VRSet("DT_PrimaryGroupName","Caption",groupname.x' ('NTGroupName.x')') leave end end return /*:VRX DDCB_Policy_Change */ DDCB_Policy_Change: say samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" 'DebugLevel' 1>'samba.!msg' 2>'samba.!error address cmd samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" 'DebugLevel' 1>'samba.!msg PolDesc = linein(samba.!msg) PolValue = linein(samba.!msg) ok = stream(Samba.!msg,'c','close') parse var PolDesc . ':' PolDesc parse var PolValue . ':' PolValue say strip(PolValue) say strip(PolDesc) ok = VRset("EF_PolValue","Value",strip(PolValue)) ok = VRSet("GB_Policy","HintText",strip(PolDesc)) return /*:VRX EF_Comment_Change */ EF_Comment_Change: if pos(':',VRGet("EF_GroupName","Value")) > 0 then ok = VRset("EF_Groupname","Value",translate(VRGet("EF_GroupName","Value"),'-',':')) return /*:VRX EF_Description_Change */ EF_Description_Change: if VRGet("EF_Description","value") <> "" then do SecondStage = 1 end else SecondStage = (SecondStage | 0) return /*:VRX EF_GGID_Change */ EF_GGID_Change: if VRGet("EF_GGID","Value") <> "" then do if datatype(VRGet("EF_GGID","Value")) <> "NUM" then ok = VRSet("EF_GGID","Value","") end return /*:VRX EF_Groupname_Change */ EF_Groupname_Change: if pos(':',VRGet("EF_GroupName","Value")) > 0 then ok = VRset("EF_Groupname","Value",translate(VRGet("EF_GroupName","Value"),'-',':')) return /*:VRX EF_Home_Change */ EF_Home_Change: if pos('NONEXISTENT', translate(VRGet("EF_Home", "Value"))) > 0 then do ok = VRset("PB_CreateHome","Enabled",0) return end if \VRFileExists( VRGet("EF_Home", "Value") ) then do ok = VRSet("EF_Home","ForeColor", "Red") ok = VRset("PB_CreateHome","Enabled",\VRGet("CB_NoHome","set")) end else do ok = VRSet("EF_Home","ForeColor", "") ok = VRset("PB_CreateHome","Enabled",0) end return /*:VRX EF_LoginPassword_KeyPress */ EF_LoginPassword_KeyPress: obj = VRInfo( "Object" ) keystr = VRGet( obj, "KeyString" ) /* say keystr */ select when keystr = "{Enter}" then call PB_LOGIN_OK_Click when keystr = "{Newline}" then call PB_LOGIN_OK_Click when keystr = "{Esc}" then call PB_LOGIN_CANCEL_Click otherwise nop end return /*:VRX EF_LoginUser_KeyPress */ EF_LoginUser_KeyPress: obj = VRInfo( "Object" ) keystr = VRGet( obj, "KeyString" ) /* say keystr */ select when keystr = "{Enter}" then ok = VRMethod( "EF_LoginPassword", "SetFocus" ) when keystr = "{Newline}" then ok = VRMethod( "EF_LoginPassword", "SetFocus" ) when keystr = "{Esc}" then call PB_LOGIN_CANCEL_Click otherwise nop end return /*:VRX EF_upPassword_Change */ EF_upPassword_Change: ok = VRSet("CB_upSWAT_Allowed","Enabled",1) return /*:VRX EF_Username_Change */ EF_Username_Change: IF options.!debug == 1 THEN say 'EF_Username_Change started' if pos(':',VRGet("EF_Username","Value")) > 0 then ok = VRset("EF_Username","Value",translate(VRGet("EF_Username","Value"),'-',':')) ok = VRSet("EF_Home","Value", Samba.!homes'\'VRGet("EF_Username","Value")) call CB_MachineAccount_Click if VRGet("EF_Username","Value") = "" then do if IsUnixUser then do IsUnixuser = 0 drop UnixUserNr ok = VRSet( "DT_UID", "BackColor", "") ok = VRSet( "DT_UID", "ForeColor", "") NextUID = _GetNextUID(VRGet("EF_Username","value")) IsUnixUser = 0 ok = VRSet("DT_UID","Caption", "UID: "NextUID) ok = VRSet("DDCB_GID","Value", NextUID) ok = VRMethod( "DDCB_GID", "Reset") ok = VRMethod( "DDCB_GID", "AddString", NextUID) ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.") ok = VRSet("EF_GECOS","Value","") ok = VRSet("EF_Home","Value","") end end else do NextUID = _GetNextUID(VRGet("EF_Username","value")) ok = VRSet("DT_UID","Caption", "UID: "NextUID) if NextUID > 65000 then do ok = VRset("EF_Description","Value",NLVGetMessage(116)) ok = VRset("CB_NoPassword","set", 1) call CB_NoPassword_Click ok = VRset("DDCB_GID","value",NextUID) ok = VRMethod("DDCB_GID","addString", NextUID) end else ok = VRset("DDCB_GID","value","513") end IF options.!debug == 1 THEN say 'EF_Username_Change done' return /*:VRX EF_Username_LostFocus */ EF_Username_LostFocus: do I = 1 to Username.0 if translate(Username.I) = translate(VRGet("EF_username","value")) then do if flags.I = "" then do IsUnixuser = 1 UnixUserNr = I ok = VRSet( "DT_UID", "BackColor", "DarkGreen") ok = VRSet( "DT_UID", "ForeColor", "White") ok = VRSet( "DT_UID", "Caption", "UID: "UID.I) ok = VRSet( "EF_GECOS","Value", GECOS.I) ok = VRSet( "DDCB_GID","Value", GID.I) ok = VRMethod( "DDCB_GID", "Reset") ok = VRMethod( "DDCB_GID", "AddString", UID.I) ok = VRMethod( "DDCB_GID", "AddStringList", "GGID.") ok = VRSet( "EF_Home","Value", _PathStrOS2(Home.I)) end else do Msg.Type = "E" Msg.Text = NLVGetMessage( 105) call _ShowMsg ok = VRSet("EF_username","value","") ok = VRMethod("EF_username","SetFocus") end leave end end return /*:VRX Fini */ Fini: window = VRWindow() call VRSet window, "Visible", 0 drop window return 0 /*:VRX GetBootDrive */ GetBootDrive: /* Use SysBootDrive if possible */ If Rxfuncadd('SysBootDrive', 'RexxUtil', 'SysBootDrive') Then Return Left(Value('RUNWORKPLACE',,'OS2ENVIRONMENT'),2) Else Return SysBootDrive() /*:VRX Group_Members_Close */ Group_Members_Close: call Group_Members_Fini return /*:VRX Group_Members_Create */ Group_Members_Create: call Group_Members_Init ok = VRSet("Group_Members","Caption", NLVGetMessage(89)||' "'CurNTGroupName'"') CALL NLVSetText 'PB_GroupMembersOK', 'Caption', 2 ok = VRMethod("LB_GroupMembers","Reset") ok = VRSet("Main", 'Pointer', 'Wait' ) say samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg address cmd samba.!netexe' rpc group members "'CurNTGroupName'" 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else do do while lines(samba.!msg) <> 0 groupmember = linein(samba.!msg) say groupmember ok = VRMethod("LB_GroupMembers","AddString", groupmember) end ok = stream(Samba.!msg,"c","close") end ok = VRSet("Main", 'Pointer', '' ) return /*:VRX Group_Members_Fini */ Group_Members_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX Group_Members_Init */ Group_Members_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Halt */ Halt: signal _VREHalt return /*:VRX Init */ Init: window = VRWindow() call VRMethod window, "CenterWindow" call VRSet window, "Visible", 0 call VRMethod window, "Activate" drop window return /*:VRX IPB_AccountFlags_Click */ IPB_AccountFlags_Click: ok = VRSet("IPB_AccountFlags","PicturePath", "#16;#16") ok = VRSet("IPB_Profile","PicturePath", "#27;#27") ok = VRSet("IPB_Memberships","PicturePath", "#28;#28") ok = VRSet("GB_Flags","Left", 140) ok = VRSet("GB_Flags","Top", 140) ok = VRSet("GB_Flags","Width", VRGet("GB_upOuter","Width") - 280) ok = VRSet("GB_Flags","Height",VRGet("GB_upOuter","Height") - 280) ok = VRSet("GB_GroupMemberShips","Visible", 0) ok = VRset("GB_Profile", "Visible", 0) ok = VRSet("GB_Flags","Visible", 1) return /*:VRX IPB_GroupAdd_Click */ IPB_GroupAdd_Click: call Contextmenu_GroupAdd_Click return /*:VRX IPB_GroupDel_Click */ IPB_GroupDel_Click: call Contextmenu_GroupDel_Click return /*:VRX IPB_GroupMap_Click */ IPB_GroupMap_Click: call Contextmenu_GroupMap_Click return /*:VRX IPB_GroupScript_Click */ IPB_GroupScript_Click: call Contextmenu_GroupRebuildScript_Click return /*:VRX IPB_GroupUnMap_Click */ IPB_GroupUnMap_Click: call Contextmenu_GroupUnMap_Click return /*:VRX IPB_GroupWellknown_Click */ IPB_GroupWellknown_Click: call Contextmenu_GroupWellKnown_Click return /*:VRX IPB_Memberships_Click */ IPB_Memberships_Click: ok = VRSet("IPB_AccountFlags","PicturePath", "#26;#26") ok = VRSet("IPB_Profile","PicturePath", "#27;#27") ok = VRSet("IPB_Memberships","PicturePath", "#18;#18") ok = VRSet("GB_GroupMemberShips","Left", 140) ok = VRSet("GB_GroupMemberShips","Top", 140) ok = VRSet("GB_GroupMemberShips","Width", VRGet("GB_upOuter","Width") - 280) ok = VRSet("GB_GroupMemberShips","Height",VRGet("GB_upOuter","Height") - 280) ok = VRSet("GB_GroupMemberShips","Visible", 1) ok = VRset("GB_Flags", "Visible", 0) ok = VRset("GB_Profile", "Visible", 0) ok = VRMethod("LB_upGroups","Reset") ok = VRSet("Main", 'Pointer', 'Wait' ) address cmd samba.!netexe' rpc user info 'Username.CurUserNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else do do while lines(samba.!msg) <> 0 ok = VRMethod("LB_upGroups","AddString", linein(samba.!msg)) end ok = stream(Samba.!msg,"c","close") end ok = VRSet("Main", 'Pointer', '' ) return /*:VRX IPB_Paper_Click */ IPB_Paper_Click: if VRInfo("Left") > VRInfo("Top") then call Activate min(CurrentPageNr+1,Pages) if VRInfo("Left") <= VRInfo("Top") then call Activate max(CurrentPageNr-1,1) return /*:VRX IPB_Profile_Click */ IPB_Profile_Click: ok = VRSet("IPB_AccountFlags","PicturePath", "#26;#26") ok = VRSet("IPB_Profile","PicturePath", "#17;#17") ok = VRSet("IPB_Memberships","PicturePath", "#28;#28") ok = VRSet("GB_Profile","Left", 140) ok = VRSet("GB_Profile","Top", 140) ok = VRSet("GB_Profile","Width", VRGet("GB_upOuter","Width") - 280) ok = VRSet("GB_Profile","Height",VRGet("GB_upOuter","Height") - 280) ok = VRSet("CN_UserProperties","Width",VRGet("GB_Profile","Width")-240) ok = VRset("GB_Flags", "Visible", 0) ok = VRSet("GB_GroupMemberShips","Visible", 0) ok = VRSet("GB_Profile","Visible", 1) return /*:VRX IPB_UserAdd_Click */ IPB_UserAdd_Click: call Contextmenu_UserAdd_Click return /*:VRX IPB_UserDel_Click */ IPB_UserDel_Click: call Contextmenu_UserDel_Click return /*:VRX IPB_UserJoinGroup_Click */ IPB_UserJoinGroup_Click: call Contextmenu_UserJoinGroup_Click return /*:VRX IPB_UserLeaveGroup_Click */ IPB_UserLeaveGroup_Click: call Contextmenu_UserLeaveGroup_Click return /*:VRX Join_Group_Close */ Join_Group_Close: call Join_Group_Fini return /*:VRX Join_Group_Create */ Join_Group_Create: call Join_Group_Init CALL NLVSetText 'Join_Group', 'Caption', 80 CALL NLVSetText 'DT_JoinGroup', 'Caption', 81 CALL NLVSetText 'PB_JoinOK', 'Caption', 2 CALL NLVSetText 'PB_JoinCancel', 'Caption', 3 call VRSet "LB_Groups", "Painting", 0 ok = VRMethod("LB_Groups","AddStringList", "NTGroupName.") address cmd samba.!netexe' rpc user info 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else do do while lines(samba.!msg) <> 0 AlreadyMember = linein(samba.!msg) ok = VRMethod( "LB_Groups", "DeleteString", AlreadyMember ) if settings.!FixErrors then do do I = 1 to NTGroupName.0 if AlreadyMember = NTGroupName.I then do if pos(Username.SelNr,GUsers.I) = 0 then do Gusers.I = Username.SelNr','Gusers.I ok = VRMethod("CN_Groups", "SetFieldData", GRH.I, GUsersFH, Gusers.I) call _GroupWrite end end end end end ok = stream(Samba.!msg,"c","close") end call VRSet "LB_Groups", "Painting", 1 return /*:VRX Join_Group_Fini */ Join_Group_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX Join_Group_Init */ Join_Group_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Leave_Group_Close */ Leave_Group_Close: call Leave_Group_Fini return /*:VRX Leave_Group_Create */ Leave_Group_Create: call Leave_Group_Init CALL NLVSetText 'Leave_Group', 'Caption', 85 CALL NLVSetText 'DT_LeaveGroup', 'Caption', 86 CALL NLVSetText 'PB_LeaveOK', 'Caption', 2 CALL NLVSetText 'PB_LeaveCancel', 'Caption', 3 address cmd samba.!netexe' rpc user info 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else do call VRSet "LB_LeaveGroups", "Painting", 0 do while lines(samba.!msg) <> 0 ok = VRMethod("LB_LeaveGroups","AddString", linein(samba.!msg)) end ok = stream(Samba.!msg,"c","close") call VRSet "LB_LeaveGroups", "Painting", 1 end return /*:VRX Leave_Group_Fini */ Leave_Group_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX Leave_Group_Init */ Leave_Group_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Main_Close */ Main_Close: call Quit return /*:VRX Main_Create */ Main_Create: options.!debug = 0 /* Default title */ Msg.Title = VRGet("Main", "Caption") call _LoadOtherFuncs call _IniRead call _NLVSetup /* Nationalized title */ Msg.Title = VRGet("Main", "Caption") call _InitTempdir call _ParseCommandLine StartSamba = \_SambaRunning() call _SambaInit if ErrorState then call _OnErrorDisable if StartSamba then do address cmd samba.!smbcmd' start' end if \_SambaRunning() then do Msg.Text = NLVGetMessage(107) Msg.Type = "E" call _ShowMsg call Quit return end else if StartSamba then do Msg.Text = NLVGetMessage(109) Msg.Type = "I" call _ShowMsg end call _SambaGetProperties call _FindHtpasswd call _ContainersInit call _MasterPasswdRead call _Login call _SmbpasswdRead call _SmbUserMapRead call _GroupRead call _SmbGroupsRead call _GUIInit call _ContainerPopulate call _ContGroupsPopulate call _PoliciesPopulate ok = VRMethod("PB_Exit","SetFocus") call TAB_1_Click call Main_Resize return /*:VRX Main_Resize */ Main_Resize: IF options.!debug == 1 THEN say 'Main_Resize() started.' MainWin = "Main" ok = VRSet(MainWin,"Painting", 0) /* ok = VRset(MainWin,"Visible", 0) */ ok = VRSet(MainWin,"Width",max(VRget(MainWin,"Width"),Pages*TabWidth+300)) ok = VRset("GB_Main","width",VRget(MainWin,"Width")-150) ok = VRset("GB_Main","Height",VRget(MainWin,"Height")-1175-240) ok = VRset("GB_Main2","width",VRget("GB_Main","Width")-260) ok = VRset("GB_Main2","Height",VRget("GB_Main","Height")-275) ok = VRset("GB_VerticalLine","Left",VRget("GB_Main2","Width")-60) ok = VRset("GB_VerticalLine","Height",VRget("GB_Main2","Height")-410) ok = VRset("IPB_Paper","Left",VRget("GB_Main2","width")-420) ok = VRset("GB_HorLineTop","Width",VRget("GB_Main2","width")-440) ok = VRset("GB_HorLineTop","Width",VRget("GB_Main2","width")-440) ok = VRset("GB_LineSubtitle","Width",VRget("GB_Main2","width")-480) do I = 1 to Pages /* say 'Page_'I'='max(PageHeight,VRget("GB_Main2","Height")-600) */ ok = VRSet("Page_"I,"Height", max(PageHeight,VRget("GB_Main2","Height")-600)) ok = VRSet("Page_"I,"Width", max(PageWidth,VRget("GB_Main2","Width")-450)) end /* Main window buttons */ ok = VRSEt("PB_RPC", "top",VRGet("GB_Main","Height")+305) ok = VRSEt("PB_Help", "top",VRGet("GB_Main","Height")+305) ok = VRSEt("PB_Save", "top",VRGet("GB_Main","Height")+305) ok = VRSEt("PB_Refresh","top",VRGet("GB_Main","Height")+305) ok = VRSEt("PB_Exit", "top",VRGet("GB_Main","Height")+305) ok = VRSEt("PB_About", "top",VRGet("GB_Main","Height")+305) /* Users page */ ok = VRset("CN_Users","Top", 120) ok = VRset("CN_Users","Left", 20) ok = VRset("CN_Users","Width", VRGet("Page_1","Width")-600) ok = VRset("CN_Users","Height", VRGet("Page_1","Height")-360) ok = VRset("CB_SmbOnly","Left", 20) ok = VRset("CB_SmbOnly","Top", VRGet("CN_Users","Height")+120 ) ok = VRSet("IPB_UserAdd", "Top", 120 ) ok = VRSet("IPB_UserAdd", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_UserDel", "Top", 720 ) ok = VRSet("IPB_UserDel", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_UserJoinGroup", "Top", 1320 ) ok = VRSet("IPB_UserJoinGroup", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_UserLeaveGroup", "Top", 1920 ) ok = VRSet("IPB_UserLeaveGroup", "Left", VRGet("CN_Users","Width") + 80 ) /* Groups page */ ok = VRset("CN_Groups","Top", 120) ok = VRset("CN_Groups","Left", 20) ok = VRset("CN_Groups","Width", VRGet("Page_2","Width")-600) ok = VRset("CN_Groups","Height", VRGet("Page_2","Height")-360) ok = VRSet("IPB_GroupAdd", "Top", 120 ) ok = VRSet("IPB_GroupAdd", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_GroupMap", "Top", 720 ) ok = VRSet("IPB_GroupMap", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_GroupDel", "Top", 1320 ) ok = VRSet("IPB_GroupDel", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_GroupUnMap", "Top", 1920 ) ok = VRSet("IPB_GroupUnMap", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_GroupScript", "Top", 2520 ) ok = VRSet("IPB_GroupScript", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRSet("IPB_GroupWellknown", "Top", 3120 ) ok = VRSet("IPB_GroupWellknown", "Left", VRGet("CN_Users","Width") + 80 ) ok = VRset("CB_SmbGroupsOnly","Left", 20) ok = VRset("CB_SmbGroupsOnly","Top", VRGet("CN_Groups","Height")+120 ) ButtonDist= 1120 ButtonNr = 6 ButtonPos = format(max((VRget(MainWin,"Width")-ButtonDist*ButtonNr)/2,0),,0) ok = VRSEt("PB_RPC", "left",ButtonPos+ButtonDist*(ButtonNr-6)) ok = VRSEt("PB_Save", "left",ButtonPos+ButtonDist*(ButtonNr-5)) ok = VRSEt("PB_Refresh","left",ButtonPos+ButtonDist*(ButtonNr-4)) ok = VRSEt("PB_Help", "left",ButtonPos+ButtonDist*(ButtonNr-3)) ok = VRSEt("PB_About", "left",ButtonPos+ButtonDist*(ButtonNr-2)) ok = VRSEt("PB_Exit", "left",ButtonPos+ButtonDist*(ButtonNr-1)) ok = VRSEt("PB_RPC", "width",ButtonDist-80) ok = VRSEt("PB_Save", "width",ButtonDist-80) ok = VRSEt("PB_Refresh","width",ButtonDist-80) ok = VRSEt("PB_Help", "width",ButtonDist-80) ok = VRSEt("PB_About", "width",ButtonDist-80) ok = VRSEt("PB_Exit", "width",ButtonDist-80) /* check and empty event queue, trash spurious resize events */ EventString = '' TrashedResize = 0 do until EventString = 'nop' EventString = VREvent('N') if EventString <> 'nop' then do if EventString = 'CALL 'MainWin'_Resize' then TrashedResize = 1 else interpret eventString end end if TrashedResize then CALL Main_Resize ok = VRSet(MainWin, "Painting", 1) /* ok = VRset(MainWin,"Visible", 1) */ IF options.!debug == 1 THEN say 'Main_Resize() done.' return /*:VRX MapGroup_Close */ MapGroup_Close: call MapGroup_Fini return /*:VRX MapGroup_Create */ MapGroup_Create: call MapGroup_Init CALL NLVSetText 'MapGroup', 'Caption', 60 CALL NLVSetText 'PB_GroupMapOK', 'Caption', 2 CALL NLVSetText 'PB_GroupMapCancel', 'Caption', 3 CALL NLVSetText 'DT_NTGroupname', 'Caption', 61 CALL NLVSetText 'DT_NTGroupComment', 'Caption', 52 CALL NLVSetText 'DT_NTRID', 'Caption', 62 CALL NLVSetText 'DT_NTGroupType', 'Caption', 63 CALL NLVSetText 'RB_NTGroupType_domain','Caption', 64 CALL NLVSetText 'RB_NTGroupType_builtin','Caption', 65 CALL NLVSetText 'RB_NTGroupType_local','Caption', 66 ok = VRSet("EF_NTGroupName","Value", GroupName.SelGNr) ok = VRSet("EF_NTRID","Value", GGID.SelGNr) NTGroupType = 'domain' return /*:VRX MapGroup_Fini */ MapGroup_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX MapGroup_Init */ MapGroup_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX Page1_Create */ Page1_Create: Return /*:VRX Page1_Init */ Page1_Init: call _ContainerInit return /*:VRX Page2_Create */ Page2_create: Return /*:VRX Page2_init */ Page2_init: return /*:VRX Page3_Create */ Page3_create: Return /*:VRX Page3_Init */ Page3_Init: return /*:VRX Page4_Create */ Page4_Create: Return /*:VRX Page4_init */ Page4_init: return /*:VRX Page5_Create */ Page5_Create: return /*:VRX Page5_Init */ Page5_Init: return /*:VRX Paper_Init */ Paper_Init: ok = VRSet("IPB_Paper","Width" ,VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRSet("IPB_Paper","Height",VRMethod( "Screen", "PixelsToTwips", 32 )) ok = VRset("IPB_Paper","Left",VRget("GB_Main2","width")-420) return /*:VRX PB_About_Click */ PB_About_Click: window = VRLoadSecondary( "About", "W" ) return /*:VRX PB_AboutOK_Click */ PB_AboutOK_Click: call About_Close return /*:VRX PB_AddUserCancel_Click */ PB_AddUserCancel_Click: call AddUser_Close return /*:VRX PB_AddUserOK_Click */ PB_AddUserOK_Click: IF options.!debug == 1 THEN say 'PB_AddUserOK_Click started.' if VRGet("EF_username","Value") ="" then do Msg.type = "E" Msg.Text = NLVGetMessage( 101 ) call _ShowMsg IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.' return end if VRGet("EF_password","Value") ="" & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do Msg.type = "E" Msg.Text = NLVGetMessage( 102 ) call _ShowMsg IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.' return end if VRGet("EF_password_repeat","Value") ="" & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do Msg.type = "E" Msg.Text = NLVGetMessage( 103 ) call _ShowMsg IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.' return end if VRGet("EF_password","Value") <> VRGet("EF_password_repeat","Value") then do Msg.type = "E" Msg.Text = NLVGetMessage( 104 ) call _ShowMsg IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.' return end if length(VRGet("EF_password","Value")) < MinPWLength & \(VRGet("CB_NoPassword","Set") | VRGet("CB_MachineAccount","Set")) then do Msg.type = "E" Msg.Text = NLVGetMessage( 117 ) call _ShowMsg IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.' return end if (substr(VRGet("DT_UID","Caption"),6) = VRGet("DDCB_GID","Value")) & (substr(VRGet("DT_UID","Caption"),6) < 65000) then do Msg.Type = "W" Msg.Text = NLVGetMessage(115) ok = _MsgYesNo() if ok = 2 then do IF options.!debug == 1 THEN say 'PB_AddUserOK_Click aborted.' return end end if IsUnixUser then nx = UnixUserNr else do nx = Username.0 + 1 Username.0 = nx end Username.nx = VRGet("EF_Username","Value") UID.nx = substr(VRGet("DT_UID","Caption"),6) GID.nx = VRGet("DDCB_GID","Value") if settings.!WriteMasterPwd = 1 then do call rxFuncAdd "Crypt", "RxCrypt", "RxCrypt" itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" salt = "" do i = 1 to 8 salt = salt || substr( itoa64, random( 0, 63 ) + 1, 1 ) end password.nx = Crypt(VRGet("EF_password","Value"), salt ) end else password.nx = "*" loginclass.NX = '' /* dummy value */ pwchange.NX = '0' /* dummy value */ deact.NX = '0' /* dummy value */ gecos.NX = VRGet("EF_GECOS","Value") /* Full name */ home.NX = _PathStrkLIBC(VRGet("EF_Home","Value")) shell.NX = '/usr/sbin/nologin' /* dummy value */ lmhash.NX = "" nthash.NX = "" flags.NX = "" lct.NX = "" Status.nx = "" call _MasterpasswdWrite call _PasswordDBRewrite if pwd_mkdbRC = 0 then do if \VRGet("CB_UnixUserOnly","set") then do call _useraddsmb if SecondStage then do command = "" newflags = "" if VRGet("EF_Description","value") <> "" then command = ' --account-desc="'VRGet("EF_Description","value")'" ' if VRGet("CB_Password_doesnt_expire","set") then newFlags = NewFlags||"X" if VRGet("CB_Deactivated","set") then newFlags = NewFlags||"D" if NewFlags <> "" then command = command||' -c "['NewFlags']"' say ' 'samba.!pdbeditexe' --user='Username.nx' --modify 'command' 'DebugLevel' 2>'samba.!error' 1>'samba.!msg address cmd samba.!pdbeditexe' --user='Username.nx' --modify 'command' 'DebugLevel' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */ end /* if GID.NX <> UID.NX then call _SmbGroupMembersSync GID.NX else call _SmbGroupMembersSync 513 call _GroupWrite call _ContGroupsPopulate */ end end call PB_Refresh_Click call AddUser_Close IF options.!debug == 1 THEN say 'PB_AddUserOK_Click done.' return /*:VRX PB_ChooseHome_Click */ PB_ChooseHome_Click: TargetDir = _DirDialog("",Samba.!homes) if TargetDir = "" then return ok = VRSet("EF_Home","value", TargetDir) drop TargetDir return /*:VRX PB_CreateHome_Click */ PB_CreateHome_Click: if translate(VRGet("EF_Home","Value")) = "\NONEXISTENT" | translate(VRGet("EF_Home","Value")) = "\DEV\NULL" then return ok = SysMkDir(VRGet("EF_Home","Value")) call EF_Home_Change return /*:VRX PB_Exit_Click */ PB_Exit_Click: say 'start PB_Cancel_Click' Call Quit say 'done PB_Cancel_Click' return /*:VRX PB_GroupAddCancel_Click */ PB_GroupAddCancel_Click: call AddGroup_Close return /*:VRX PB_GroupAddOK_Click */ PB_GroupAddOK_Click: if \UnixGroupOnly then do if VRGet("EF_Comment","Value") <> "" then Comment = ' -C "'VRGet("EF_Comment","Value")'"' else Comment = "" address cmd samba.!netexe' rpc group add "'VRGet("EF_GroupName","Value")'" 'Comment' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else call _SambaShowMsg end else do if VRGet("CB_AutomaticGGID","set") then call _kLibcGroupAdd VRGet("EF_GroupName","Value") , _GetNextGID() else call _kLibcGroupAdd VRGet("EF_GroupName","Value") , VRget("EF_GGID","Value") call PB_Save_Click end call PB_Refresh_Click call AddGroup_Close return /*:VRX PB_GroupMapCancel_Click */ PB_GroupMapCancel_Click: call MapGroup_Close return /*:VRX PB_GroupMapOK_Click */ PB_GroupMapOK_Click: if VRGet("EF_NTGRoupComment","value") <> "" then Comment = ' comment="'VRGet("EF_NTGRoupComment","value")'"' else Comment = "" /* net groupmap add rid=512 ntgroup="Domain Admins" unixgroup="root" type=domain */ say address cmd samba.!netexe' groupmap add rid='VRGet("EF_NTRID","Value")' ntgroup="'VRGet("EF_NTGroupName","Value")'" unixgroup="'GroupName.SelGnr'" type='NTGroupType' 'Comment' 'debuglevel 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 if RC <> 0 then call _SambaShowError else do call _SambaShowMsg blGusers = translate(Gusers.SelGnr,' ',',') do I = 1 to words(blGusers) address cmd samba.!netexe' rpc group addmem "'VRGet("EF_NTGroupName","Value")'" 'word(BlGusers,I)' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError else call _SambaShowMsg say samba.!netexe' RC = 'RC end end call PB_Refresh_Click call MapGroup_Close return /*:VRX PB_GroupMembersOK_Click */ PB_GroupMembersOK_Click: IF options.!debug == 1 THEN say 'PB_Group_MembersOK_Click started.' call Group_Members_Close IF options.!debug == 1 THEN say 'PB_Group_MembersOK_Click done.' return /*:VRX PB_Help_Click */ PB_Help_Click: Msg.Title = VRGet("Main", "Caption") Msg.Type = "I" Msg.Text = "Not implemented" call _ShowMsg return /*:VRX PB_JoinCancel_Click */ PB_JoinCancel_Click: call Join_Group_Close return /*:VRX PB_JoinOK_Click */ PB_JoinOK_Click: ok = VRMethod( "LB_Groups", "GetSelectedStringList", SelGroups. ) if SelGroups.0 = 0 then return do I = 1 to SelGroups.0 if SelGroups.I = "(klibc group)" then iterate ok = VRCopyFile(samba.!group, samba.!group'.bak') say samba.!netexe' rpc addmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg address cmd samba.!netexe' rpc group addmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then do call _SambaShowError ok = VRCopyFile(samba.!group'.bak', samba.!group) end else call _SambaShowMsg /* call _SmbGroupMembersSync SelGroups.I call _GroupWrite */ end call Join_Group_Close call PB_Refresh_Click return /*:VRX PB_LeaveCancel_Click */ PB_LeaveCancel_Click: call Leave_Group_Close return /*:VRX PB_LeaveOK_Click */ PB_LeaveOK_Click: ok = VRMethod( "LB_LeaveGroups", "GetSelectedStringList", SelGroups. ) if SelGroups.0 = 0 then return do I = 1 to SelGroups.0 ok = VRCopyFIle(samba.!group, samba.!group'.bak') say samba.!netexe' rpc delmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg address cmd samba.!netexe' rpc group delmem "'SelGroups.I'" 'Username.SelNr' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then do call _SambaShowError ok = VRCopyFile(samba.!group'.bak', samba.!group) end else call _SambaShowMsg /* call _SmbGroupMembersSync SelGroups.I call _GroupWrite */ end call Leave_Group_Close call PB_Refresh_Click return /*:VRX PB_LOGIN_CANCEL_Click */ PB_LOGIN_CANCEL_Click: say " Login Abort" call SW_LOGIN_Close exit 0 return /*:VRX PB_LOGIN_OK_Click */ PB_LOGIN_OK_Click: IF options.!debug == 1 THEN say " SW_LOGIN OK started" Credentials.!Username = VRGet("EF_LoginUser","Value") Credentials.!Password = VRGet("EF_LoginPassword","Value") if pos("4OS2", value("COMSPEC",,"OS2ENVIRONMENT")) = 0 then UserCred = '--user='Credentials.!username'%'Credentials.!password else UserCred = '--user='Credentials.!username'%%'Credentials.!password Call SW_LOGIN_Close IF options.!debug == 1 THEN say " SW_LOGIN OK done" return /*:VRX PB_pdbeditConsole_Click */ PB_pdbeditConsole_Click: Buttons.1 = NLVGetMessage(2) Buttons.2 = NLVGetMessage(3) Buttons.0 = 2 command = ' --account-desc= --fullname --homedir= --drive= --script= --profile= --domain= -c "[NDHLX]"' id = VRPrompt( VRWindow(), 'pdbedit --user='Username.CurUserNr' --modify', "command", "pdbedit Console", "Buttons.", buttons.1, buttons.2 ) if id = 2 then return say samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'command' 'DebugLevel' 2>'samba.!error address cmd samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'command' 'DebugLevel' 2>'samba.!error if RC <> 0 then call _SambaShowError call _UserPropertiesGet Username.CurUserNr return /* Settable account flags N: No password required D: Account disabled H: Home directory required L: Automatic Locking X: Password does not expire Account Types: U: Regular user account T: Temporary duplicate of other account M: MNS logon user account W: Workstation Trust Account S: Server Trust Account I: Domain Trust Account */ /*:VRX PB_PolReset_Click */ PB_PolReset_Click: say samba.!pdbeditexe' --policies-reset 'DebugLevel' 1>'samba.!msg address cmd samba.!pdbeditexe' --policies-reset 'DebugLevel' 1>'samba.!msg call _SambaShowMsg "description unknown parameter" return /*:VRX PB_PolUpdate_Click */ PB_PolUpdate_Click: say samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" -C 'VRGet("EF_PolValue","Value")' 'DebugLevel' 1>'samba.!msg address cmd samba.!pdbeditexe' -P "'VRGet("DDCB_Policy","Value")'" -C 'VRGet("EF_PolValue","Value")' 'DebugLevel' 1>'samba.!msg call _SambaShowMsg "description unknown parameter" return /*:VRX PB_Refresh_Click */ PB_Refresh_Click: call _Refresh return /*:VRX PB_RPC_Click */ PB_RPC_Click: Buttons.1 = NLVGetMessage(2) Buttons.2 = NLVGetMessage(3) Buttons.0 = 2 command = 'group' id = VRPrompt( VRWindow(), "net rpc", "command", "net rpc Console", "Buttons.", buttons.1, buttons.2 ) if id = 2 then return say samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg address cmd samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg if RC <> 0 then call _SambaShowError; else call _SambaShowMsg call PB_Refresh_Click return /*:VRX PB_Save_Click */ PB_Save_Click: IF options.!debug == 1 THEN say 'PB_Save_Click() started' call _MasterpasswdWrite call _GroupWrite call _PasswordDBRewrite call _SmbUserMapWrite IF options.!debug == 1 THEN say 'PB_Save_Click() done' return /*:VRX PB_upCancel_Click */ PB_upCancel_Click: call UserProperties_Close return /*:VRX PB_upSave_Click */ PB_upSave_Click: /* U: Regular user account T: Temporary duplicate of other account M: MNS logon user account W: Workstation Trust Account S: Server Trust Account I: Domain Trust Account */ /* we mask out flags that cannot be modified anyway here */ CurFlags = translate(CurFlags,' ','UTMWSI') if VRGet("CB_upResetLogonHours", "set") then newcommand = newcommand||' -Z' say samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'newcommand' -c "['CurFlags']" 'DebugLevel' 2>'samba.!error /* ' 1>'samba.!msg */ address cmd samba.!pdbeditexe' --user='Username.CurUserNr' --modify 'newcommand' -c "['CurFlags']" 'DebugLevel' 2>'samba.!error /* ' 1>'samba.!msg */ if RC <> 0 then call _SambaShowError /* ; else call _SambaShowMsg */ else do if VRGet("EF_upPassword","Value") <> "" | VRGet("EF_upPassword_repeat","Value") <> "" then do /* Password change! */ if VRGet("EF_upPassword","Value") <> VRGet("EF_upPassword_repeat","Value") then do Msg.type = "E" Msg.Text = NLVGetMessage( 104 ) call _ShowMsg return end else do if length(VRGet("EF_upPassword","Value")) < MinPWLength then do Msg.type = "E" Msg.Text = NLVGetMessage( 117 ) call _ShowMsg return end else do pwdfile = TempDir'newpwd' call lineout pwdfile, VRGet("EF_upPassword","value") call lineout pwdfile, VRGet("EF_upPassword","value") ok = stream(pwdfile,"c","close") say samba.!smbpasswdexe' -a 'Username.CurUserNr' -s <'pwdfile' 2>'samba.!error address cmd samba.!smbpasswdexe' -a 'Username.CurUserNr' -s <'pwdfile' 2>'samba.!error' 1>'samba.!msg smbpasswdrc = rc if rc <> 0 then call _SambaShowError else call _SambaShowMsg ok = SysFileDelete(pwdfile) if SwatAuth then do /* we always remove the old swat */ say ' 'samba.!htpasswdexe' -D "'swatusers'" 'Username.CurUserNr address cmd samba.!htpasswdexe' -D "'swatusers'" 'Username.CurUserNr /* ' 2>'samba.!error' 1>'samba.!msg if rc <> 0 then call _SambaShowError; else call _SambaShowMsg */ if VRGet("CB_upSWAT_Allowed","Set") then do if VRFileExists(swatusers) then cFlag = ""; else cFlag="c" say ' 'samba.!htpasswdexe' -b'cFLag' "'swatusers'" 'Username.CurUserNr' **********' address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" 'Username.CurUserNr' 'VRGet("EF_upPassword","value")' 2>'samba.!error' 1>'samba.!msg if rc <> 0 then call _SambaShowError else call _SambaShowMsg end end if settings.!WriteMasterPwd = 1 then do call rxFuncAdd "Crypt", "RxCrypt", "RxCrypt" itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" salt = "" do i = 1 to 8 salt = salt || substr( itoa64, random( 0, 63 ) + 1, 1 ) end password.CurUserNr = Crypt(VRGet("EF_upPassword","Value"), salt ) call _UserRecWriteBackToStems call PB_Save_Click end end end end if pos("--fullname", newcommand) > 0 & Settings.!SyncFullName = 1 then do parse var newcommand dummy '--fullname="'NewGECOS'"' dummy GECOS.CurUserNr = NewGECOS SyncedFullName = 1 end call UserProperties_Close end return /*:VRX PushbackAll */ PushbackAll: Pages = 4 /* Tab distance from top */ TabTop = 20 TabWidth = VRMethod( "Screen", "PixelsToTwips", 78 ) TabHeight= VRMethod( "Screen", "PixelsToTwips", 24 ) /* Page Position */ PageLeft = 120 PageTop = PageLeft + TabTop + 330 /* Page size */ PageHeight = 3000 PageWidth = 3000 ok = VRset("DT_PageName", "Caption", "") ok = VRSet("GB_Main","Left", 0) ok = VRSet("GB_Main","Top", TabTop+230) do I = 1 to Pages ok = VRSet("Page_"I,"BackColor", "") ok = VRSet("TAB_"I,"Top", TabTop) ok = VRSet("TAB_"I,"PicturePath","#2"||I||";#2"||I) ok = VRSet("TAB_"I,"Left",TabWidth*(I-1)+PageLeft) ok = VRSet("TAB_"I,"Width",TabWidth) ok = VRSet("TAB_"I,"Height",TabHeight) ok = VRSet("Page_"I,"Height", max(PageHeight,VRget("GB_Main2","Height")-600)) ok = VRSet("Page_"I,"Width", max(PageWidth,VRget("GB_Main2","Width")-450)) ok = VRSet("Page_"I,"Left", PageLeft) ok = VRSet("Page_"I,"Top", PageTop) ok = VRSet("Page_"I,"Visible", 0) end return /*:VRX Quit */ Quit: if VRGet("Main","WindowState") = "Maximized"|, VRGet("Main","WindowState") = "Minimized" then ok = VRMethod("Main", "Restore") call _IniWrite ok = VRREdirectStdio("OFF") call _SambaFinish ok = SysFileDelete(smbdoutput) if VRParseFileName(samba.!smbpasswd,"DP")||'\' = TempDir then do ok = SysFileDelete(samba.!smbpasswd) end window = VRWindow() call VRSet window, "Shutdown", 1 drop window return /*:VRX RB_NTGroupType_builtin_Click */ RB_NTGroupType_builtin_Click: NTGroupType = 'builtin' return /*:VRX RB_NTGroupType_domain_Click */ RB_NTGroupType_domain_Click: NTGroupType = 'domain' return /*:VRX RB_NTGroupType_local_Click */ RB_NTGroupType_local_Click: NTGroupType = 'local' return /*:VRX SW_LOGIN_Close */ SW_LOGIN_Close: call SW_LOGIN_Fini return /*:VRX SW_LOGIN_Create */ SW_LOGIN_Create: call SW_LOGIN_Init CALL NLVSetText 'SW_LOGIN', 'Caption', 31 CALL NLVSetText 'DT_LoginUser', 'Caption', 32 CALL NLVSetText 'DT_LoginPassword','Caption', 33 CALL NLVSetText 'PB_LOGIN_OK', 'Caption', 2 CALL NLVSetText 'PB_LOGIN_CANCEL', 'Caption', 3 if Credentials.!Username = "" then ok = VRSet("EF_LoginUser","Value", value("USER",,"OS2ENVIRONMENT")) else ok = VRSet("EF_LoginUser","Value", Credentials.!Username) if \_UserIsValid(VRGet("EF_LoginUser","Value")) & value("USER",,"OS2ENVIRONMENT") <> "" then do Msg.Title =VRGet("Main", "caption") Msg.Type = "E" Msg.Text = NLVGetMessage(111, VRGet("EF_LoginUser","Value")) call _ShowMsg ok = VRSet("EF_LoginUser","Value","root") end if VRGet("EF_LoginUser","Value") <> "" then ok = VRMethod("EF_LoginPassword","Setfocus") return /*:VRX SW_LOGIN_Fini */ SW_LOGIN_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_LOGIN_Init */ SW_LOGIN_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return /*:VRX TAB_1_Click */ TAB_1_Click: call Activate 1 return /*:VRX TAB_2_Click */ TAB_2_Click: call Activate 2 return /*:VRX TAB_3_Click */ TAB_3_Click: call Activate 3 return /*:VRX TAB_4_Click */ TAB_4_Click: call Activate 4 return /*:VRX TAB_5_Click */ TAB_5_Click: call Activate 5 return /*:VRX UserProperties_Close */ UserProperties_Close: call UserProperties_Fini if SyncedFullName = 1 | SyncedPrimGID = 1 then call PB_Save_Click call PB_Refresh_Click return /*:VRX UserProperties_Create */ UserProperties_Create: call UserProperties_Init CALL NLVSetText 'UserProperties', 'Caption', 120 upTabWidth = VRMethod( "Screen", "PixelsToTwips", 136 ) upTabHeight= VRMethod( "Screen", "PixelsToTwips", 24 ) ok = VRset("IPB_Accountflags","Width", upTabWidth) ok = VRset("IPB_Profile","Width", upTabWidth) ok = VRset("IPB_Memberships","Width", upTabWidth) ok = VRset("IPB_Accountflags","Top", 40) ok = VRset("IPB_Profile", "Top", 40) ok = VRset("IPB_Memberships", "Top", 40) ok = VRset("IPB_Accountflags","Left", upTabWidth*0+40) ok = VRset("IPB_Profile", "Left", upTabWidth*1+40) ok = VRset("IPB_Memberships", "Left", upTabWidth*2+40) ok = VRset("IPB_Accountflags","Height", upTabHeight) ok = VRset("IPB_Profile", "Height", upTabHeight) ok = VRset("IPB_Memberships", "Height", upTabHeight) CALL NLVSetText 'PB_upSave', 'Caption', 10 CALL NLVSetText 'PB_upCancel', 'Caption', 3 ok = VRSet("PB_pdbeditconsole",'Caption', "pdbedit "||word(NLVGetMessage(23),2)) CALL NLVSetText 'DT_upAccountType', 'Caption', 55 CALL NLVSetText 'CB_upNoPassword', 'Caption', 20 CALL NLVSetText 'DT_upPassword', 'Caption', 33 CALL NLVSetText 'DT_upPassword_Repeat', 'Caption', 43 CALL NLVSetText 'CB_upMust_change_password', 'Caption', 46 CALL NLVSetText 'CB_upCannot_change_password', 'Caption', 47 CALL NLVSetText 'CB_upPassword_doesnt_expire', 'Caption', 48 CALL NLVSetText 'CB_upDeactivated', 'Caption', 49 CALL NLVSetText 'CB_upResetLogonHours', 'Caption', 54 CALL NLVSetText 'CB_upSWAT_Allowed', 'Caption', 35 ok = VRSet('CB_upSWAT_Allowed',"Enabled",swatAuth) CALL NLVSetText 'DT_upGroups', 'Caption', 56 CALL NLVSetText 'CB_EditableFieldsOnly', 'Caption', 45 upNrFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(130)) upTypeFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(57)) upValueFH = VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(58)) upCommandFH= VRMethod( "CN_UserProperties", "AddField", "String", NLVGetMessage(59)) ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upNrFH, "Visible", 0) ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upTypeFH, "ReadOnly", 1) ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upValueFH, "ReadOnly", 0) ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upCommandFH, "ReadOnly", 1) ok = VRMethod( "CN_UserProperties", "SetFieldAttr", upCommandFH, "Visible", 0) ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "Selected." ) if Selected.0 = 0 then return CurUserNr = VRMethod("CN_Users","GetFieldData", Selected.1, NrFH) call IPB_AccountFlags_Click ok = VRMethod("PB_upCancel", "SetFocus" ) SyncedPrimGID = 0 SyncedFullName = 0 MinPWLength = _PolicyGet("min password length") call _UserPropertiesGet Username.CurUserNr newcommand = "" return /*:VRX UserProperties_Fini */ UserProperties_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX UserProperties_Init */ UserProperties_Init: window = VRInfo( "Object" ) if( \VRIsChildOf( window, "Notebook" ) ) then do call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" end drop window return