/*: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\trunk\guitools\shared\smbtree.vrs #append U:\Develop\Samba\trunk\guitools\shared\inittempdir.vrs #append U:\Develop\Samba\trunk\guitools\shared\nlv.vrs #append U:\Develop\Samba\trunk\guitools\shared\swat.vrs #append U:\Develop\Samba\trunk\guitools\shared\sambainit.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 _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 time()' _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 number = '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 time()' _ContGroupsPopulate() done.' return /*:VRX _ContUsersPopulate */ _ContUsersPopulate: IF options.!debug == 1 THEN say time()' _ContUsersPopulate() 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 number = '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 time()' _ContUsersPopulate() 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 time()' _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 time()' _GroupRead() done, read 'groupname.0' kLIBC groups' return /*:VRX _GroupRecWriteBackToStems */ _GroupRecWriteBackToStems: IF options.!debug == 1 THEN say time()' _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 time()' _GroupRecWriteBackToStems() done' return /*:VRX _GroupWrite */ _GroupWrite: IF options.!debug == 1 THEN say time()' _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 time()' _GroupWrite() done' return /*:VRX _GUIINit */ _GUIINit: IF options.!debug == 1 THEN say time()' _GUIInit() started' /* NL Users page */ CALL NLVSetText 'GB_Users', 'Hinttext', 28 CALL NLVSetText 'CB_SmbOnly', 'Caption', 17 CALL NLVSetText 'CB_SmbOnly', 'Hinttext',121 CALL NLVSetText 'ContextMenu_UserAdd', 'Caption', 195 CALL NLVSetText 'ContextMenu_UserProperties', 'Caption', 120 CALL NLVSetText 'ContextMenu_UserDel', 'Caption', 196 CALL NLVSetText 'Contextmenu_UserDetailView', 'Caption', 118 CALL NLVSetText 'Contextmenu_UserSymbolView', 'Caption', 119 CALL NLVSetText 'PB_UserAdd', 'Caption', 195 CALL NLVSetText 'PB_UserEdit', 'Caption', 120 CALL NLVSetText 'PB_UserDel', 'Caption', 196 CALL NLVSetText 'PB_UserJoinGroup', 'Caption', 197 CALL NLVSetText 'PB_UserLeaveGroup', 'Caption', 198 /* NL Groups page */ CALL NLVSetText 'GB_Groups', 'Hinttext', 29 CALL NLVSetText 'CB_SmbGroupsOnly', 'Caption', 21 CALL NLVSetText 'CB_SmbGroupsOnly', 'Hinttext', 122 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 'PB_GroupAdd', 'Caption', 195 CALL NLVSetText 'PB_GroupDel', 'Caption', 196 CALL NLVSetText 'PB_GroupMap', 'Caption', 199 CALL NLVSetText 'PB_GroupUnmap', 'Caption', 200 CALL NLVSetText 'PB_GroupScript', 'Caption', 98 CALL NLVSetText 'PB_GroupWellKnown', 'Caption', 88 /* NL Policy page */ CALL NLVSetText 'GB_Policies', 'Hinttext',171 CALL NLVSetText 'DT_Policy', 'Caption', 172 CALL NLVSetText 'DT_PolValue', 'Caption', 173 CALL NLVSetText 'PB_PolReset', 'Caption', 174 CALL NLVSetText 'PB_PolUpdate', 'Caption', 175 /* NL Settings page */ CALL NLVSetText 'GB_Settings', 'Hinttext',30 CALL NLVSetText 'CB_FixErrors', 'Caption', 25 CALL NLVSetText 'CB_SyncFullName', 'Caption', 26 CALL NLVSetText 'CB_SyncPrimGID', 'Caption', 27 CALL NLVSetText 'CB_WriteMasterPwd', 'Caption', 190 /* Set position */ 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 /* Set fonts */ ok = VRSet("Main", "Font", Font_Main) ok = VRSet("Main", "Statusfont", Font_Status) ok = VRSet("GB_Users", "Font", Font_Page_1) ok = VRSet("GB_Groups", "Font", Font_Page_2) ok = VRSet("GB_Policies","Font", Font_Page_3) ok = VRSet("GB_Settings","Font", Font_Page_4) /* Set settings and options */ 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 ) ok = VRSet("CN_Users","Hinttext","@unixroot/etc = "UnixETC) ok = VRSet("CN_Groups","Hinttext","@unixroot/etc = "UnixETC) /* Set container layout */ call _INILayoutRead "CN_Users" call _INILayoutRead "CN_Groups" /* Common margin around controls - needed for proper resizing */ margin = ((VRGet("Main", "InteriorLeft") / 3) * 2) + 2 marginx2 = margin * 2 marginx4 = margin * 4 /* Make sure we have at least 512K temporary free space */ if _ChkTempFreeSpace() < 524288 then do Msg.Type = "W" Msg.Text = NLVGetMessage(180, TempDir) call _ShowMsg end IF options.!debug == 1 THEN say time()' _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 time()' _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 time()' OurINI = "'OurINI'"' /* Window position */ Top = VRGetIni( "Pos", "Top", OurINI , 'NoClose') Left = VRGetIni( "Pos", "Left", OurINI , 'NoClose') Width = VRGetIni( "Pos", "Width", OurINI , 'NoClose') Height= VRGetIni( "Pos", "Height", OurINI , 'NoClose') /* Window fonts */ Font_Main = VRGetIni( "Fonts", "Main", OurINI , 'NoClose' ) Font_Status = VRGetIni( "Fonts", "Statusfont", OurINI , 'NoClose' ) Font_Page_1 = VRGetIni( "Fonts", "GB_Users", OurINI , 'NoClose' ) Font_Page_2 = VRGetIni( "Fonts", "GB_Groups", OurINI , 'NoClose' ) Font_Page_3 = VRGetIni( "Fonts", "GB_Policies", OurINI , 'NoClose' ) Font_Page_4 = VRGetIni( "Fonts", "GB_Settings", OurINI , 'NoClose' ) if Font_Main = "" then Font_Main = "9.WarpSans" if Font_Status = "" then Font_Status = "9.WarpSans" if Font_Page_1 = "" then Font_Page_1 = "9.WarpSans" if Font_Page_2 = "" then Font_Page_2 = "9.WarpSans" if Font_Page_3 = "" then Font_Page_3 = "9.WarpSans" if Font_Page_4 = "" then Font_Page_4 = "9.WarpSans" /* Settings and options */ 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 options.!curpage = VRGetIni( "Options", "CurPage", OurINI) if options.!curpage = "" then options.!curpage = 1 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 time()' _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' ) ok = VRSetIni( "Options", "CurPage", options.!curpage, OurINI, 'NoClose' ) if VRget("CN_Users", "Font") <> "" then ok = VRset("GB_Users", "Font", VRget("CN_Users", "Font")) if VRget("CN_Groups", "Font") <> "" then ok = VRset("GB_Groups", "Font", VRget("CN_Groups", "Font")) call _INILayoutWrite "CN_Users" call _INILayoutWrite "CN_Groups" ok = VRSetIni( "Fonts", "GB_Users", VRGet("GB_Users","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "GB_Groups", VRGet("GB_Groups","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "GB_Settings", VRGet("GB_Settings","Font"), OurINI, 'NoClose' ) ok = VRSetIni( "Fonts", "GB_Policies", VRGet("GB_Policies","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 time()' _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', '' ) do while lines(samba.!msg) > 0 loginLine = linein(samba.!msg) if words(loginline) <> 1 then do if pos("NT_STATUS",loginline) > 0 then leave /* Bad login */ end else leave /* Good login */ /* retry - we read garbage - probably debug data */ end ok = stream(samba.!msg,'c','close') ok = SysFileDelete(samba.!msg) /* 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 = substr(loginLine, pos("NT_STATUS",loginline)) Msg.Type = "E" call _ShowMsg Credentials.!username = "" Credentials.!password = "" IF options.!debug == 1 THEN say time()' _Login() failed, credentials used were "'UserCred'"' signal EnterCredentials end IF options.!debug == 1 THEN say time()' _Login() succeeded, credentials used are "'UserCred'"' return /*:VRX _MasterpasswdRead */ _MasterpasswdRead: IF options.!debug == 1 THEN say time()' _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 time()' _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: settings.!messages = 1 /* language files exist(s) */ settings.!helpfile = 0 /* helpfiles do not exist */ settings.!nlv8dot3 = 0 /* NLV may have long filenames */ 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 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 time()' _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 time()' _ParseCommandLine() done' return /*:VRX _PasswordDBRewrite */ _PasswordDBRewrite: IF options.!debug == 1 then say time()' _PasswordDBRewrite() started' /* Reset any old rc from pwd_mkdb.exe */ pwd_mkdbrc = 0 /* delete old .db.tmp files */ ok = SysFileDelete(UnixETC'\pwd.db.tmp') ok = SysFileDelete(UnixETC'\spwd.db.tmp') /* create backups of old .db files */ ok = VRCopyFile( UnixETC'\pwd.db', UnixETC'\pwd.db.bak' ) ok = VRCopyFile( UnixETC'\spwd.db', UnixETC'\spwd.db.bak' ) /* delete old .db files */ ok = SysFileDelete(UnixETC'\pwd.db') ok = SysFileDelete(UnixETC'\spwd.db') /* Create new password db */ address cmd samba.!pwd_mkdb' -d 'unixetc' 'samba.!masterpasswd' 2>'samba.!error pwd_mkdbrc = rc if \VRFileExists(samba.!pwddb) | pwd_mkdbrc <> 0 then do call _ShowError end IF options.!debug == 1 then say time()" _PasswordDBRewrite() done ("pwd_mkdbrc")" 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 time()' _PoliciesPopulate() started' say ' 'samba.!pdbeditexe' -P -?'DebugLevel' 1>'samba.!msg' 2>'samba.!error address cmd samba.!pdbeditexe' -P -?'DebugLevel' 1>'samba.!msg' 2>'samba.!error ok = file2stem(samba.!error,"pol.", , ": !") ok = VRMethod("DDCB_Policy","AddstringList", "pol.") IF options.!debug == 1 THEN say time()' _PoliciesPopulate() done' return /*:VRX _PolicyGet */ _PolicyGet: IF options.!debug == 1 THEN say time()' _PoliciesGet("'arg(1)'") started' address cmd samba.!pdbeditexe' -P "'arg(1)'" 'DebugLevel' 1>'samba.!msg ok = file2stem(samba.!msg,"pol.") PolDesc = pol.1 PolValue = pol.2 parse var PolDesc . ': ' PolDesc parse var PolValue . ': ' PolValue IF options.!debug == 1 THEN say time()' _PoliciesGet("'PolDesc'", "'PolValue'") done' return PolValue /*:VRX _PolicySet */ _PolicySet: IF options.!debug == 1 THEN say time()' _PoliciesSet() started' IF options.!debug == 1 THEN say time()' _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 _ContUsersPopulate call _ContGroupsPopulate ok = VRSet("Main", 'Pointer', '' ) return /*:VRX _SambaGetProperties */ _SambaGetProperties: procedure expose options. samba. IF options.!debug == 1 THEN say time()' _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 time()' _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) ok = file2stem(samba.!msg,"smbmsg.", ,skipwords) 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 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 time()' _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 time()' _SmbGroupMembersSync() done' return /*:VRX _SmbGroupsRead */ _SmbGroupsRead: IF options.!debug == 1 THEN say time()' _SmbGroupsRead() started' /* Read group mapping */ groupmapf = TempDir'netgroupmap.txt' ok = SysFileDelete(groupmapf) say ' 'samba.!netexe' groupmap list -l --debuglevel=0 >'groupmapf address cmd samba.!netexe' groupmap list -l --debuglevel=0 >'groupmapf ok = file2stem(groupmapf, "groupmap.") gname.0 = 0 do G = 1 to groupmap.0 sidline = groupmap.G if pos("SID ",sidline) > 0 then do /* Found group */ gname.0 = gname.0 + 1 idx = G - 1; smbgname = strip(groupmap.idx) idx = G ; SID = substr(groupmap.idx,14) idx = G + 1; UnixGID = substr(groupmap.idx,14) idx = G + 2; Unixgroup = substr(groupmap.idx,14) idx = G + 3; GroupType = substr(groupmap.idx,14) idx = G + 4; GroupComment = substr(groupmap.idx,14) G = G + 4 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 IF options.!debug == 1 THEN say ' Found 'gname.0' mapped Samba groups.' /* Now read the group list */ grouplistf = TempDir'netgrouplist.txt' ok = SysFileDelete(grouplistf) GroupListError = 0 say ' 'samba.!netexe' rpc group -l 'DebugLevel' 'UserCred' 1>'grouplistf' 2>'samba.!error address cmd samba.!netexe' rpc group -l 'DebugLevel' 'UserCred' 1>'grouplistf' 2>'samba.!error if RC <> 0 then do call _SambaShowError GroupListError = 1 end /* Read grouplist */ ok = file2stem(grouplistf,"grouplist.","NODEL") I = 0 do G = 1 to grouplist.0 groupline = grouplist.G if pos("Group",groupline) > 0 & pos("name",groupline) > 0 & pos("Comment",groupline) > 0 then do /* The header */ commentpos = pos("Comment",groupline) do H = G + 1 to grouplist.0 grline = strip(grouplist.H) do J = 1 to words(grline) /* Check whether this is really a group */ gword = word(grline,J) if lastpos(gword,grline) = commentpos then do /* This is a group! */ i = i + 1 gline.i = grline leave end end end end end gline.0 = i IF options.!debug == 1 THEN say ' Found 'gline.0' total Samba groups.' do i = 1 to gline.0 ngroup = strip(left(gline.i,CommentPos-1)) ncomment = strip(substr(gline.i,CommentPos)) do j=1 to groupname.0 if GStatus.j = "" then iterate if ngroup = strip(left(NTGroupname.j,CommentPos-2)) 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 time()' Samba groups appear to be workable.' IF options.!debug == 1 THEN say time()'_SmbGroupsRead() done, 'gline.0' smbgroups read' return /*:VRX _SmbpasswdRead */ _SmbpasswdRead: IF options.!debug == 1 THEN say time()' _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 time()' 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 time()' _SmbpasswdRead() done, read 'sname.0-cmt-err' Samba users, 'cmt' comments, 'err' errors.' return /*:VRX _SmbUserMapRead */ _SmbUserMapRead: IF options.!debug == 1 THEN say time()' _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 time()' _SmbUserMapRead() done, 'I' user mappings read' end else IF options.!debug == 1 THEN say time()' _SmbUserMapRead() done, not installed' return /*:VRX _SmbUserMapWrite */ _SmbUserMapWrite: IF options.!debug == 1 THEN say time()' _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 time()' _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 time()' _SmbUserMapWrite() done' end else IF options.!debug == 1 THEN say time()' _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 _TabbedDialogSetup */ _TabbedDialogSetup: IF options.!debug == 1 THEN SAY time()' _TabbedDialogSetup started' w = VRLoad( "TDL_1", VRWindowPath(), "SW_Users" ) ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(15)" ") w = VRLoad( "TDL_1", VRWindowPath(), "SW_Groups" ) ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(16)" ") w = VRLoad( "TDL_1", VRWindowPath(), "SW_Policies" ) ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(170)" ") w = VRLoad( "TDL_1", VRWindowPath(), "SW_SETTINGS" ) ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(24)" ") IF options.!debug == 1 THEN SAY time()' _TabbedDialogSetup done' return /*:VRX _useraddsmb */ _useraddsmb: IF options.!debug == 1 THEN say time()' _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 time()' _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 time()' _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 time()' 'samba.!pdbeditexe' 'CurUser' -L -v 'debuglevel address cmd samba.!pdbeditexe' 'CurUser' -L -v 'DebugLevel' >'UserProperties /* Read user properties */ ok = file2stem(Userproperties,"upline.") 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 time()' _UserPropertiesGet() done' return /*:VRX _UserRecWriteBackToStems */ _UserRecWriteBackToStems: IF options.!debug == 1 THEN say time()' _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 time()' _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 = 11 SambaTeam.1 = 'Silvan Scherrer' SambaTeam.2 = 'Herwig Bauernfeind' SambaTeam.3 = 'Dmitriy Kuminov' SambaTeam.4 = 'Vitali Pelenyov' SambaTeam.5 = 'Paul Smedley' SambaTeam.6 = 'Yuri Dario' SambaTeam.7 = 'Alex Taylor' SambaTeam.8 = 'Nikolay Kolosov' SambaTeam.9 = 'All the Samba people' SambaTeam.10= 'All the ArcaNoae people' SambaTeam.11= 'All the netlabs people' ok = VRSet("About","Font", VRGet("GB_Settings","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 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 time()' 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 time()' 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 _ContUsersPopulate 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") < 446 & 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") < 446 & 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 options.!debug == 1 THEN say time()' CN_Users_DoubleClick() started' if VRInfo("Top") < 340 & VRGet("CN_Users", "View") = "Detail" then return IF options.!debug == 1 THEN say time()' CN_Users_DoubleClick() entered' RH = VRInfo("Record") CurUserNr = VRMethod("CN_Users","GetFieldData", RH, NrFH) CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH) if CurFlags <> "" then window = VRLoadSecondary( "UserProperties", "W" ) IF options.!debug == 1 THEN say time()' 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) IF options.!debug == 1 THEN say ' Selected group number = '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) IF options.!debug == 1 THEN say ' Selected group number = ' 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) IF options.!debug == 1 THEN say ' Selected group number = '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) IF options.!debug == 1 THEN say ' Selected group number = '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 "admin", 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="admin" 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 time()' Contextmenu_UserAdd_Click() started' ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." ) if SelRH.0 = 0 then do IF options.!debug == 1 THEN say time()' 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 number = 'SelNr IF options.!debug == 1 THEN say ' Is it kLIBC user only? 'IsUnixUser window = VRLoadSecondary( "AddUser", "W" ) IF options.!debug == 1 THEN say time()' Contextmenu_UserAdd_Click() done' return /*:VRX Contextmenu_UserDel_Click */ Contextmenu_UserDel_Click: IF options.!debug == 1 THEN say time()' Contextmenu_UserDel_Click() started' ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "SelRH." ) if SelRH.0 = 0 then return IF options.!debug == 1 THEN say time()' Contextmenu_UserDel_Click() entered' SelNr = VRMethod("CN_Users", "GetFieldData", SelRH.1, NrFH) IF options.!debug == 1 THEN say ' Selected user number = '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 time()' 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) IF options.!debug == 1 THEN say ' Selected user number = '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) IF options.!debug == 1 THEN say ' Selected user number = 'SelNr window = VRLoadSecondary( "Leave_Group", "W" ) return /*:VRX Contextmenu_UserProperties_Click */ Contextmenu_UserProperties_Click: ok = VRMethod( "CN_Users", "GetRecordList", "Selected", "Selected." ) if Selected.0 = 0 then return RH = Selected.1 CurUserNr = VRMethod("CN_Users","GetFieldData", RH, NrFH) CurFlags = VRMethod("CN_Users","GetFieldData", RH, FlagsFH) if CurFlags <> "" then 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: IF options.!debug == 1 THEN say time()' DDCB_Policy_Change started' PolValue = _PolicyGet(VRGet("DDCB_Policy","Value")) ok = VRset("EF_PolValue","Value",strip(PolValue)) ok = VRSet("GB_Policy","HintText",strip(PolDesc)) /* _PolicyGet sets this one */ IF options.!debug == 1 THEN say time()' DDCB_Policy_Change done' 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 time()' 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 time()' 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 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 ok = VRSet("Main", 'Pointer', 'Wait' ) if options.!Debug then ok = VRREdirectStdIO("ON") else ok = VRREdirectStdIO("OFF") /* Default title */ Msg.Title = VRGet("Main", "Caption") call _LoadOtherFuncs call _NLVSetup call _TabbedDialogSetup call _IniRead /* 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 ok = VRSet("Main", 'Pointer', '' ) call _Login ok = VRSet("Main", 'Pointer', 'Wait' ) ok = VRset("Main","Visible", 0) call _SmbpasswdRead call _SmbUserMapRead call _GroupRead call _SmbGroupsRead call _GUIInit call _ContUsersPopulate call _ContGroupsPopulate call _PoliciesPopulate ok = VRMethod("PB_Exit","SetFocus") call Main_Resize ok = VRSet("Main","WindowIcon", "$2") ok = VRSet("Main", 'Pointer', '' ) return /*:VRX Main_Resize */ Main_Resize: IF options.!debug == 1 THEN say time()' Main_Resize() started.' MainWin = "Main" ok = VRSet(MainWin,"Painting", 0) /* Basic measurements */ main_iwidth = VRGet("Main","InteriorWidth") /* Width of window client-area */ main_iheight = VRGet("Main","InteriorHeight") /* Height of window client-area */ sbar_height = 0 /* 209 */ /* Height of status-bar */ pbtn_dist = 980 pbtn_nr = 5 pbtn_pos = max((main_iwidth - pbtn_Dist * pbtn_Nr)%2, 0)+ margin pbtn_height = 400 /* Height of the panels' internal button areas */ pbtn_width = 940 /* ipbtn_width = VRGet("IPB_GroupScript","Width") */ pane_height = main_iheight- sbar_height - pbtn_height - margin * 7 /* Height of notebook panel */ pane_width = main_iwidth - marginx2 /* Width of notebook panel */ /* Tabbed Dialog */ ok = VRset("TDL_1", "Top", marginx2 ) ok = VRset("TDL_1", "Left", margin ) ok = VRset("TDL_1", "Width", pane_width ) ok = VRset("TDL_1", "Height", pane_height ) /* Main window buttons */ ok = VRSet("PB_RPC", "top", VRGet("TDL_1","Height")+marginx4) ok = VRSet("PB_Help", "top", VRGet("TDL_1","Height")+marginx4) ok = VRSet("PB_Save", "top", VRGet("TDL_1","Height")+marginx4) ok = VRSet("PB_Refresh","top", VRGet("TDL_1","Height")+marginx4) ok = VRSet("PB_Exit", "top", VRGet("TDL_1","Height")+marginx4) ok = VRSet("PB_About", "top", VRGet("TDL_1","Height")+marginx4) ok = VRset("GB_Users","Top", margin ) ok = VRset("GB_Users","Left", marginx2) ok = VRset("GB_Users","Width", pane_width - 760) ok = VRset("GB_Users","Height", pane_height- 1020) ok = VRset("CN_Users","Top", marginx2) ok = VRset("CN_Users","Left", marginx2) ok = VRset("CN_Users","Width", pane_width - 760 - pbtn_width- marginx4-marginx2 ) ok = VRset("CN_Users","Height", pane_height- 1020- pbtn_height- margin ) ok = VRset("GB_Groups","Top", margin ) ok = VRset("GB_Groups","Left", marginx2) ok = VRset("GB_Groups","Width", pane_width - 760) ok = VRset("GB_Groups","Height", pane_height- 1020) ok = VRset("CN_Groups","Top", marginx2) ok = VRset("CN_Groups","Left", marginx2) ok = VRset("CN_Groups","Width", pane_width - 760 - pbtn_width- marginx4-marginx2 ) ok = VRset("CN_Groups","Height", pane_height- 1020- pbtn_height- margin ) ok = VRset("GB_Policies","Top", margin) ok = VRset("GB_Policies","Left", marginx2) ok = VRset("GB_Policies","Width", pane_width - 760) ok = VRset("GB_Policies","Height", pane_height- 1020) ok = VRset("GB_Settings","Top", margin) ok = VRset("GB_Settings","Left", marginx2) ok = VRset("GB_Settings","Width", pane_width - 760) ok = VRset("GB_Settings","Height", pane_height- 1020) /* Users page */ ok = VRSet("CB_SmbOnly","Left", marginx2) ok = VRSet("CB_SmbOnly","Top", VRGet("CN_Users","Height")+ marginx2+margin ) ok = VRSet("PB_UserAdd", "Top", pbtn_height*1 + marginx2 ) ok = VRSet("PB_UserAdd", "Left", VRGet("CN_Users","Width") + marginx4 ) ok = VRSet("PB_UserEdit", "Top", pbtn_height*2 + margin * 3 ) ok = VRSet("PB_UserEdit", "Left", VRGet("CN_Users","Width") + marginx4 ) ok = VRSet("PB_UserDel", "Top", pbtn_height*3 + margin * 4 ) ok = VRSet("PB_UserDel", "Left", VRGet("CN_Users","Width") + marginx4 ) ok = VRSet("PB_UserJoinGroup", "Top", pbtn_height*4 + margin * 5 ) ok = VRSet("PB_UserJoinGroup", "Left", VRGet("CN_Users","Width") + marginx4 ) ok = VRSet("PB_UserLeaveGroup","Top", pbtn_height*5 + margin * 6 ) ok = VRSet("PB_UserLeaveGroup","Left", VRGet("CN_Users","Width") + marginx4 ) /* Groups page */ ok = VRSet("CB_SmbGroupsOnly","Left", marginx2) ok = VRSet("CB_SmbGroupsOnly","Top", VRGet("CN_Groups","Height")+marginx2+margin ) ok = VRSet("PB_GroupAdd", "Top", pbtn_height*1 + marginx2 ) ok = VRSet("PB_GroupAdd", "Left", VRGet("CN_Groups","Width") + marginx4 ) ok = VRSet("PB_GroupDel", "Top", pbtn_height*2 + margin * 3 ) ok = VRSet("PB_GroupDel", "Left", VRGet("CN_Groups","Width") + marginx4 ) ok = VRSet("PB_GroupMap", "Top", pbtn_height*4 + margin * 5 ) ok = VRSet("PB_GroupMap", "Left", VRGet("CN_Groups","Width") + marginx4 ) ok = VRSet("PB_GroupUnMap", "Top", pbtn_height*5 + margin * 6 ) ok = VRSet("PB_GroupUnMap", "Left", VRGet("CN_Groups","Width") + marginx4 ) ok = VRSet("PB_GroupScript", "Top", pbtn_height*7 + margin * 8 ) ok = VRSet("PB_GroupScript", "Left", VRGet("CN_Groups","Width") + marginx4 ) ok = VRSet("PB_GroupWellknown","Top", pbtn_height*8 + margin * 9 ) ok = VRSet("PB_GroupWellknown","Left", VRGet("CN_Groups","Width") + marginx4 ) 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 time()' 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 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 time()' 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 time()' 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 time()' 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 time()' 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 time()' 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 time()' 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 time()' 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 time()' 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_GroupAdd_Click */ PB_GroupAdd_Click: call Contextmenu_GroupAdd_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_GroupDel_Click */ PB_GroupDel_Click: call Contextmenu_GroupDel_Click return /*:VRX PB_GroupMap_Click */ PB_GroupMap_Click: call Contextmenu_GroupMap_Click 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 time()' PB_Group_MembersOK_Click started.' call Group_Members_Close IF options.!debug == 1 THEN say time()' PB_Group_MembersOK_Click done.' return /*:VRX PB_GroupScript_Click */ PB_GroupScript_Click: call Contextmenu_GroupRebuildScript_Click return /*:VRX PB_GroupUnMap_Click */ PB_GroupUnMap_Click: call Contextmenu_GroupUnMap_Click return /*:VRX PB_GroupWellKnown_Click */ PB_GroupWellKnown_Click: call Contextmenu_GroupWellKnown_Click 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 time()' PB_Save_Click() started' call _MasterpasswdWrite call _GroupWrite call _PasswordDBRewrite call _SmbUserMapWrite IF options.!debug == 1 THEN say time()' 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 PB_UserAdd_Click */ PB_UserAdd_Click: call Contextmenu_UserAdd_Click return /*:VRX PB_UserDel_Click */ PB_UserDel_Click: call Contextmenu_UserDel_Click return /*:VRX PB_UserEdit_Click */ PB_UserEdit_Click: call Contextmenu_UserProperties_Click return /*:VRX PB_UserJoinGroup_Click */ PB_UserJoinGroup_Click: call Contextmenu_UserJoinGroup_Click return /*:VRX PB_UserLeaveGroup_Click */ PB_UserLeaveGroup_Click: call Contextmenu_UserLeaveGroup_Click 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_Groups_Close */ SW_Groups_Close: call SW_Groups_Fini return /*:VRX SW_Groups_Create */ SW_Groups_Create: call SW_Groups_Init return /*:VRX SW_Groups_Fini */ SW_Groups_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_Groups_Init */ SW_Groups_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 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 SW_Policies_Close */ SW_Policies_Close: call SW_Policies_Fini return /*:VRX SW_Policies_Create */ SW_Policies_Create: call SW_Policies_Init return /*:VRX SW_Policies_Fini */ SW_Policies_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_Policies_Init */ SW_Policies_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 SW_Settings_Close */ SW_Settings_Close: call SW_Settings_Fini return /*:VRX SW_Settings_Create */ SW_Settings_Create: call SW_Settings_Init return /*:VRX SW_Settings_Fini */ SW_Settings_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_Settings_Init */ SW_Settings_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 SW_Users_Close */ SW_Users_Close: call SW_Users_Fini return /*:VRX SW_Users_Create */ SW_Users_Create: call SW_Users_Init return /*:VRX SW_Users_Fini */ SW_Users_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX SW_Users_Init */ SW_Users_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 TDL_1_PageSelected */ TDL_1_PageSelected: page = VRInfo("Page") CurrentPageNr = page /* ok = VRSet("DT_STATUSBAR","Caption", VRGet("Main", "HintText")) */ select when page = 1 then do /* Users */ ok = VRSet("Main","WindowIcon", "$2") end when page = 2 then do /* Groups */ ok = VRSet("Main","WindowIcon", "$3") end when page = 3 then do /* Policies */ ok = VRSet("Main","WindowIcon", "$4") end when page = 4 then do /* Settings */ ok = VRSet("Main","WindowIcon", "$5") end otherwise nop end return /*:VRX TDL_2_PageSelected */ TDL_2_PageSelected: uppage = VRInfo("Page") select when uppage = 1 then do /* properties */ ok = VRSet("UserProperties","WindowIcon", "$2") end when uppage = 2 then do /* profile */ ok = VRSet("UserProperties","WindowIcon", "$5") end when uppage = 3 then do /* memberships */ ok = VRSet("UserProperties","WindowIcon", "$3") end otherwise nop end return /*:VRX UP_Flags_Close */ UP_Flags_Close: call UP_Flags_Fini return /*:VRX UP_Flags_Create */ UP_Flags_Create: call UP_Flags_Init return /*:VRX UP_Flags_Fini */ UP_Flags_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX UP_Flags_Init */ UP_Flags_Init: IF options.!debug == 1 THEN say time()' UP_Flags_Init started' window = VRInfo( "Object" ) call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" drop window IF options.!debug == 1 THEN say time()' UP_Flags_Init done' return /*:VRX UP_GroupMemberShips_Close */ UP_GroupMemberShips_Close: call UP_GroupMemberShips_Fini return /*:VRX UP_GroupMemberShips_Create */ UP_GroupMemberShips_Create: call UP_GroupMemberShips_Init return /*:VRX UP_GroupMemberShips_Fini */ UP_GroupMemberShips_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX UP_GroupMemberShips_Init */ UP_GroupMemberShips_Init: IF options.!debug == 1 THEN say time()' UP_GroupMemberShips_Init started' window = VRInfo( "Object" ) call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" drop window IF options.!debug == 1 THEN say time()' UP_GroupMemberShips_Init done' return /*:VRX UP_Profile_Close */ UP_Profile_Close: call UP_Profile_Fini return /*:VRX UP_Profile_Create */ UP_Profile_Create: call UP_Profile_Init return /*:VRX UP_Profile_Fini */ UP_Profile_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX UP_Profile_Init */ UP_Profile_Init: IF options.!debug == 1 THEN say time()' UP_Profile_Init started' window = VRInfo( "Object" ) call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" drop window IF options.!debug == 1 THEN say time()' UP_Profile_Init done' 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("GB_Profile","Left", marginx2) ok = VRSet("GB_Profile","Top", margin) ok = VRSet("GB_Profile","Width", VRGet("TDL_2","Width") - marginx4*4) ok = VRSet("GB_Profile","Height",VRGet("TDL_2","Height") - marginx4*8+marginx2) ok = VRSet("CN_UserProperties","Width",VRGet("GB_Profile","Width")-marginx4) ok = VRSet("GB_Flags","Left", marginx2) ok = VRSet("GB_Flags","Top", margin) ok = VRSet("GB_Flags","Width", VRGet("GB_Profile","Width")) ok = VRSet("GB_Flags","Height",VRGet("GB_Profile","Height")) ok = VRSet("GB_GroupMemberShips","Left", marginx2) ok = VRSet("GB_GroupMemberShips","Top", margin) ok = VRSet("GB_GroupMemberShips","Width",VRGet("GB_Profile","Width") ) ok = VRSet("GB_GroupMemberShips","Height",VRGet("GB_Profile","Height")) 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 ok = file2stem(samba.!msg,"memberships.") ok = VRMethod("LB_upGroups","AddStringList", "memberships.") end ok = VRSet("Main", 'Pointer', '' ) 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) ok = VRMethod("PB_upCancel", "SetFocus" ) SyncedPrimGID = 0 SyncedFullName = 0 MinPWLength = _PolicyGet("min password length") call _UserPropertiesGet Username.CurUserNr newcommand = "" call UserProperties_Resize ok = VRSet("UserProperties","Visible",1) return /*:VRX UserProperties_Fini */ UserProperties_Fini: window = VRInfo( "Window" ) call VRDestroy window drop window return /*:VRX UserProperties_Init */ UserProperties_Init: IF options.!debug == 1 THEN SAY time()' UserProperties_Init started' ok = VRSet("UserProperties","Visible",0) ok = VRMethod("UserProperties","CenterWindow") w = VRLoad( "TDL_2", VRWindowPath(), "UP_Flags" ) ok = VRMethod( "TDL_2", "InsertPage", w,"+ "NLVGetMessage(168)" ") w = VRLoad( "TDL_2", VRWindowPath(), "UP_Profile" ) ok = VRMethod( "TDL_2", "InsertPage", w,"+ "NLVGetMessage(167)" ") w = VRLoad( "TDL_2", VRWindowPath(), "UP_GroupMemberShips" ) ok = VRMethod( "TDL_2", "InsertPage", w,"+ "NLVGetMessage(169)" ") IF options.!debug == 1 THEN SAY time()' UserProperties_Init done' return /*:VRX UserProperties_Resize */ UserProperties_Resize: IF options.!debug == 1 THEN say time()' User_Properties_Resize() started.' upMain = "UserProperties" ok = VRSet(upMain,"Painting", 0) /* Basic measurements */ upMain_iwidth = VRGet(upMain,"InteriorWidth") /* Width of upMain client-area */ upMain_iheight = VRGet(upMain,"InteriorHeight") /* Height of upMain client-area */ pbtn_dist = 1500 pbtn_nr = 3 pbtn_pos = max((upMain_iwidth - pbtn_Dist * pbtn_Nr)%2, 0)+ margin pbtn_height = 400 /* Height of the panels' internal button areas */ pbtn_width = 1460 pane_height = upMain_iheight- pbtn_height - margin * 7 /* Height of notebook */ pane_width = upMain_iwidth - marginx2 /* Width of the notebook panel */ /* Tabbed Dialog */ ok = VRset("TDL_2", "Top", marginx2 ) ok = VRset("TDL_2", "Left", margin ) ok = VRset("TDL_2", "Width", pane_width ) ok = VRset("TDL_2", "Height", pane_height ) /* Buttons */ ok = VRSet("PB_upSave", "top", VRGet("TDL_2","Height")+marginx4+margin) ok = VRSet("PB_pdbeditConsole", "top", VRGet("TDL_2","Height")+marginx4+margin) ok = VRSet("PB_upCancel", "top", VRGet("TDL_2","Height")+marginx4+margin) ok = VRSet("PB_upSave", "left",pbtn_pos+pbtn_dist*(pbtn_nr-3)) ok = VRSet("PB_pdbeditConsole", "left",pbtn_pos+pbtn_dist*(pbtn_nr-2)) ok = VRSet("PB_upCancel", "left",pbtn_pos+pbtn_dist*(pbtn_nr-1)) ok = VRset("GB_Profile","Top", margin ) ok = VRset("GB_Profile","Left", marginx2) ok = VRset("GB_Profile","Width", pane_width - 760) ok = VRset("GB_Profile","Height", pane_height- 1020) ok = VRset("CN_UserProperties","Top", marginx2) ok = VRset("CN_UserProperties","Left", marginx2) ok = VRset("CN_UserProperties","Width", pane_width - 760 - marginx4-marginx2 ) ok = VRset("CN_UserProperties","Height", pane_height- 1020- pbtn_height ) ok = VRset("CB_EditableFieldsOnly","Top", pane_height- 1020- pbtn_height + margin*3) ok = VRset("GB_Flags","Top", margin ) ok = VRset("GB_Flags","Left", marginx2) ok = VRset("GB_Flags","Width", pane_width - 760) ok = VRset("GB_Flags","Height", pane_height- 1020) ok = VRset("GB_GroupMemberships","Top", margin ) ok = VRset("GB_GroupMemberships","Left", marginx2) ok = VRset("GB_GroupMemberships","Width", pane_width - 760) ok = VRset("GB_GroupMemberships","Height", pane_height- 1020) ok = VRset("DT_upGroups", "Top", marginx2) ok = VRset("DT_upGroups", "Left", marginx2) ok = VRset("LB_upGroups", "Top", marginx2*6) ok = VRset("LB_upGroups", "Left", marginx2) ok = VRset("LB_upGroups", "Width", pane_width - 760 - marginx4-marginx2 ) ok = VRset("LB_upGroups", "Height",pane_height- 1020- VRGet("LB_upGroups","Top")- marginx2) /* 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 'upMain'_Resize' then TrashedResize = 1 else interpret eventString end end if TrashedResize then CALL Main_Resize ok = VRSet(upMain,"Painting", 1) IF options.!debug == 1 THEN say time()' User_Properties_Resize() done.' return