StrataFrame Forum

Accessing files encrypted with Cryptor during design time

http://forum.strataframe.net/Topic9424.aspx

By AlexSosa - 6/7/2007

We use Cryptor to keep dbfs encrypted in disk.  With the VFP code below we can access those encrypted tables via VfpOleDb.

Fast forward to Strataframe.  I need to access those tables from Strataframe both at runtime and at design time.  Runtime seems straightforward (though I haven't done it yet Smile ), but where would you place the equivalent code in the development environment so that the BO mapper can access the encrypted dbf?

Thanks,

Alex

CLOSE ALL

* Instantiate Cryptor and tell it to watch disk access by oledb32.dll

poCryptor = CreateObject("XitechCryptor.Cryptor")

poCryptor.WatchDLL("oledb32.dll")

* Register table plemp.dbf with Cryptor as encrypted

MyCryptor('plemp.dbf')

* Access plemp.dbf via vfpoledb

LOCAL oConn as "adodb.connection"

LOCAL oRS as "adodb.recordset"

oConn = CREATEOBJECT('adodb.connection')

oRS = CREATEOBJECT('adodb.recordset')

cConnStrng = "Provider=vfpoledb;Data Source=" + "z:\VPay950\Contab\sosa"

oConn.Open(cConnStrng)

oRS = oConn.Execute("SELECT * FROM plemp")

?oRS.Fields("ccodemp").Value

oRS.Close()

oConn.Close()

FUNCTION MyCryptor

PARAMETER tcFile

lcPassword = 'password'

lnAlgorithmNumber = xxx

poCryptor.Register(tcFile,lcPassword,lnAlgorithmNumber)

RETURN

By Ivan George Borges - 6/8/2007

Hi Alex.

I think the BO Mapper will have no problem mapping your VFP table. Have you gone through the process to do it? (create your BO in your project, go to BOMapper, right-click your project and go to Properties, fill in the OLE DB Connection String, right-click you BO, choose Properties and select OLE DB from the radio button group and them Select Source button.) This should take you to your .DBC, letting you choose your .dbf

I'm not sure where your Encryptor should be instantiated, but I guess the guys here will have a good idea to give you.

Abraços.

By Trent L. Taylor - 6/8/2007

Yeah, I have been thinking about this and really there is no way at the moment within the designer to have pre and post initialization code.  I have no experience with this Cryptor product you are referring to....have you tried to pull a schema through the BO Mapper?  If so, does it just not recognize the file structures or do you get an error?  Last, is there anyway that you could just have some unencrypted files that you use to map your schemas since you already know you can work around this at run-time?
By AlexSosa - 6/13/2007

Hi Trent,

Good idea about using unencrypted files to map the schemas, and I may have to do that.  In the mean time, when testing the the run-time access I found a rights problem instantiating the Cryptor object.  This is not a Strataframe problem, of course, just a result of being new to .NET, but could you give me some guidance, please?  Thanks.

Alex

At this point an error ocurrs at runtime: Security exception was unhandled.
Imports XitechCryptorModule Module1
Public oXitechCryptor As XitechCryptor.Cryptor
Sub Main()
' Instantiate Cryptor and tell it to watch disk access by oledb32.dll
oXitechCryptor = New XitechCryptor.Cryptor()
 
System.Security.SecurityException was unhandled
Message="System.Security.Permissions.SecurityPermission"
Source="ConsoleApplication1"
StackTrace: at ConsoleApplication1.Module1.Main()
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
 
By Trent L. Taylor - 6/13/2007

Well, if I were guessing, I would think that you are running some .NET code on a network drive.  By default .NET code cannot execute on a network drive because the security policies are not trusted.  You can get around this by changing your security settings through the .NET Framework Configuration console.

Start -> Control Panel -> Administrative Tools -> Microsoft.NET Framework 2.0 Configuration

You will want to adjust the Zone Security for your computer.  Select the Local Intranet and provide Full Trust.  This is the first place I would look.

By AlexSosa - 6/13/2007

Trent,

Exactly, thank you.  Some day I will know enough about .NET as I know of VFP, hopefully.

Alex

By Trent L. Taylor - 6/14/2007

Exactly, thank you.  Some day I will know enough about .NET as I know of VFP, hopefully.

You are already well on your way.  It is just like anything else, you just have to familiarize yourself with it and then you move forward faster and faster.  Smile