Unable to delete inherited file permissions in VB6 on Windows 2012 R2 - com

I have a legacy VB6 COM application that I’ve recently had to migrate from a Windows 2008 R2 to a Windows 2012 R2 environment. The application works well apart from a section that strips the inherited permissions of certain (confidential) folders created on remote machines. The same code (below) works as expected on Windows 2008, however on Windows 2012 (using the same AD service account), will only delete permissions explicitly created on the folder in question. Does anyone know what has changed or what I’m doing wrong? I have noticed that the version of activeds.dll (C:\Windows\SysWOW64) has increased from 6.1.7601.17514 to 6.3.9600.17415.
Public Sub RemoveInheritedPermissions(ByVal sNTFSPath As String)
Dim sec As New ADsSecurityUtility
Dim sd As SecurityDescriptor
Dim ace As New AccessControlEntry
Dim dacl As Object
Set sd = sec.GetSecurityDescriptor(sNTFSPath, ADS_PATH_FILE, ADS_SD_FORMAT_IID)
Set dacl = sd.DiscretionaryAcl
For Each ace In dacl
dacl.RemoveAce ace
Next
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sNTFSPath, ADS_PATH_FILE, sd, ADS_SD_FORMAT_IID
Set sec = Nothing
Set sd = Nothing
Set dacl = Nothing
Set ace = Nothing
End Sub
Thanks in advance.

Related

Connect Oracle SQL to VBA

I am able to connect Python to my Oracle SQL DB on a Windows computer, but strangely enough I cannot seem to get it working from VBA.
For reference, this is the Python Code to connect:
cx_Oracle.connect(f'{self.user}/{self.pwd}#//{self.host}:{self.port}/{self.service_name}')
I have tried replicating this similar structure in my VBA code, but I get an error message. Here is the code I've been using:
Sub CallDB_Return_Flexible(stSQL As String, rstStart As Range)
Dim sqlConn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim rtn As Boolean
Dim cmd As New ADODB.Command
Dim cs As String
'On Error Resume Next
Set sqlConn = New ADODB.Connection
cs = "Provider=OraOLEDB.Oracle;User ID=myuserID;Password=myPsswd;Data Source=host:port/service_name;"
sqlConn.ConnectionString = cs
sqlConn.CommandTimeout = 10000
sqlConn.Open
I get the following error messages:
1) The system cannot find message text for message text 0x80040e0c in the message file for OraOLEDB.
2) Sometimes, dependent on the iteration of the connection I use (IE a TNS connection), I get a TNS listener error message.
I currently have the ActiveX 6.1 Data Objects Library enabled. Furthermore, I am on a 64-bit machine with a 64-bit Oracle client installed. I have a 64-bit Office. I am quite certain I have a 64-bit ADO as well - my ODAC (if this is the same) is the same as the 64 bit version online. I have an ODP.NET of 2.12 and another with 4.121 in the registry. I just have an ODP.NET.Managed of 4.12.
This doesn't make much sense to me, how in one language I can connect with no issues, but in another I cannot!
I backtested using an earlier ActiveX Data Library - this solved it.
Thank you!!!!!

Sage200c SDK crashing in webforms

We are having a problem with the Sage 200c Extra 2018 SDK when used in Web Forms.
We have created solution with library, win forms and web forms project. We have noticed that when using the 'Win Forms project' it works, but the same example in 'Web Forms project' crashes. Sage 200c SDK documentation does not exclusively talk about Win or Web forms and what configuration each may need.
Could you please help us to get this working in web forms? We have an older version of the SDK working on an older version of Sage 200 v8.
We have upgraded Sage 200 v8 to Sage 200c Extra 2018 Summer Enhancements and tested it with the new client and all is working.
I have noticed on sage City similar questions but no answer.
Here
Here is our code sample:
Private Shared Sub FindCore200()
' get registry info for Sage 200 server path
Dim path As String = String.Empty
Dim root As RegistryKey = Registry.CurrentUser
Dim key As RegistryKey = root.OpenSubKey(REG_PATH)
If key IsNot Nothing Then
Dim value As Object = key.GetValue(REGKEY_VALUE)
If value IsNot Nothing Then
path = TryCast(value, String)
End If
End If
' refer to all installed assemblies based on location of default one
If String.IsNullOrEmpty(path) = False Then
Dim commonDllAssemblyName As String = System.IO.Path.Combine(path, DEFAULT_ASSEMBLY)
If (System.IO.File.Exists(commonDllAssemblyName)) Then
Dim defaultAssembly As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom(commonDllAssemblyName)
Dim type As Type = defaultAssembly.[GetType](ASSEMBLY_RESOLVER)
Dim method As MethodInfo = type.GetMethod(RESOLVER_METHOD)
Dim x = method.Invoke(Nothing, Nothing)
Dim ok = 1
End If
End If
End Sub
when running the application, it always crashes on
application = New Sage.Accounting.Application
Exception Type: System.TypeInitializationException
Message: The type initializer for 'Sage.Accounting.Application' threw an exception.
Inner Exception:
Exception Type: System.IO.FileNotFoundException
Message: Could not load file or assembly 'Sage.MMSAdmin.Util, Version=19.0.0.0, Culture=neutral, PublicKeyToken=b2daa66d74953d11' or one of its dependencies. The system cannot find the file specified.
Are your application pools targeted to the correct version of .net and bit architecture?
If you can physically see the assembly in the path but the app can't, it's usually down to having the wrong version of .net configured. Going from such an old version to a new one, likely requires a .net version change (2.0 to 4.5 for example). It may just be that your winforms solution is targeted to the correct config and it's definitely worth comparing your build and application settings. Check that your targeting the correct CPU architecture in your build too.

WorkSite SDK - Cannot create ActiveX component

I am attempting to learn how to develop applications to interact with the Autonomy WorkSite 8.5 server and have found the WorkSite DB Administrators COM Developers Reference Guide, it has helped me somewhat and I can now see the types of objects that I can interface with however, I am stumbling on showing the members of a group.
My code is as follows. This is for a VB.NET Windows Forms application.
Dim ObjNRDMS As IMANADMIN.NRTDMS
Dim ObjSessions As IMANADMIN.NRTSessions
Dim ObjSession As IMANADMIN.NRTSession
Dim ServerName As String
ServerName = "SERVERNAME"
' Create the NRTDMS object
ObjNRDMS = GetObject("IMANADMIN.NRTDMS")
' Add the Server to the NRTSessions object and
' get a NRTSession object for the server
ObjSessions = ObjNRDMS.Sessions
ObjSessions.Add(ServerName)
ObjSession = ObjSessions.Item(1)
' Login to the Server
ObjSession.TrustedLogin()
Dim ObjDBs As IMANADMIN.NRTDatabases
Dim ObjDB As IMANADMIN.NRTDatabase
Dim ObjGroup As IMANADMIN.NRTGroup
' ObjSession is a previously defined NRTSession object
' Get the first database defined for ObjSession object
ObjDBs = ObjSession.Databases
ObjDB = ObjDBs.Item(1)
ObjGroup = ObjDB.GetGroup("TEST")
txtOutput.AppendText(ObjGroup.Users.ToString)
However, when I debug this code in Visual Studio (2008), I get the error:
Cannot create ActiveX component at the line `ObjNRDMS =
GetObject("IMANADMIN.NRTDMS")
I have run regsvr32 iManAdmin.dll.
Can anyone offer any assistance on this problem?
I've read on page 21 of the DB Admin COM guide that it mentions to execute iManAdmin - REGSERVER from the command prompt, however this will not work for me with Windows reporting that the file does not have a open with program set.
I ended up resolving this issue by using the iManage worksite Interop.iManAdmin.dll

how do I set folder share programmatically in vb.net

I have Client-Server environment and developed a project for Client-Server.
I need to share a folder of my Server machine programmatically using VB.NET
Please help me.
Here's one example which shows the concept using ManagmentClass. It's C# but easily convertible to VB.NET:
UPDATE:
Directory.CreateDirectory("C:\MyTestShare")
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams.Item("Description") = "My Files Share"
inParams.Item("Name") = "My Files Share"
inParams.Item("Path") = "C:\MyTestShare"
inParams.Item("Type") = 0
If (DirectCast(managementClass.InvokeMethod("Create", inParams, Nothing).Properties.Item("ReturnValue").Value, UInt32) <> 0) Then
Throw New Exception("Unable to share directory.")
End If
I have code that looks similar to this which works on vista and win2k3 machines, but when i try it on Windows server 2008 R2 (with recent updates) it fails with an "access denied" error. I've tried your exact code above and the same result. I am an Admin on the box and I have tried disabling UAC but without any effect.
(i know this isn't an answer, I have no power to comment)

List SQL Express 2005 instances using VB6 code

How to list all the instances of SQL Server 2005 Express Edition using vb6 application?
This will list all SQL Server instances using SQL-DMO. You will need to filter for Express instances.
Function listServers(vControl As Object)
Dim oApp As SQLDMO.Application
Dim oNames As SQLDMO.NameList
Set oApp = New SQLDMO.Application
Set oNames = oApp.ListAvailableSQLServers()
For Each oName In oNames
vControl.AddItem oName
Next
End Function
From here.
This SO question says that it won't find Express instances; need to use SQLBrowseConnect.
This sample is using SQLBrowseConnect API.