Ok, I have gone through almost every question, PHP Manual and post around this issue all over the internet. Nothing seems to help.
I'm working on a project that needs me to authenticate (or at least be able to lookup the UID for) different users in my organisation on an Active Directory. For connecting and authenticating, they have provided me with a dll file which has the functions necessary to authenticate. I need to use this dll file and the functions within to get my application working.
Below are the different things I have tried so far along with errors for each.
- Use dl() to load the DLL.
I tried using
dl('filename.dll');
and got the error
Call to undefined function dl() in C:\xampp\htdocs\OOP_curater\index.php on line 16
After looking around I came across this and this I realized it's no more supported.
I then tried placing the dll in C:\xampp\php\ext and adding an extention line to php.ini. (Just for the heck of it) restarting php gave me an error message saying it's not a valid PHP extention.
- Tried using COM()
I then tried using
$action = new COM("ProjectName.FunctionName") or die ("Could not initialise MS Word object.");
and got the following error
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `ProjectName.FunctionName': Invalid syntax ' in C:\xampp\htdocs\OOP_curater\index.php:3 Stack trace: #0 C:\xampp\htdocs\OOP_curater\index.php(3): com->com('FBA_Provider1.a...') #1 {main} thrown in C:\xampp\htdocs\OOP_curater\index.php on line 3
Looking around got me to links similar to this. I realized I need to register the DLL so tried
regsvr32 C:\xampp\htdocs\OOP_curater\filename.dll
and got the error
DllRegisterServer entry point was not found
I then tried
regsvr32 /i /n C:\xampp\htdocs\OOP_curater\filename.dll
and got a "DLL Install was not found" error.
I must admit, I'm still not sure if I got the (Projectname.FunctionName) part right, i really could not understand most of the documentation around this topic.
- Tried using DOTNET()
I then tried the following code
$comobj = new DOTNET("projectname", "projectname.function");
and got this error
Fatal error: Uncaught exception 'com_exception' with message 'Failed to instantiate .Net object [CreateInstance] [0x80070002] The system cannot find the file specified. ' in C:\xampp\htdocs\OOP_curater\index.php:21 Stack trace: #0 C:\xampp\htdocs\OOP_curater\index.php(21): dotnet->dotnet('ProjectName', 'Function') #1 {main} thrown in C:\xampp\htdocs\OOP_curater\index.php on line 21
I now have the following questions with regards to loading a DLL for PHP
What is the best way to load a DLL where:
a. It is not really a PHP function
b. The source is not available
c. It cannot be registered (assuming due to the errors above)
d. It cannot be recompiled to be a PHP Extension / Register able
Few Things to Note
- The setup is currently on XXAMP for development and testing.
- I do not have admin rights, but can arrange for it if necessary.
- Production environment would be on a windows server running IIS.
I have very little knowledge in .net and Active Directory which is why I find this even tougher to handle. Also given the length of the question, hope I didn't miss out on anything important. Do let me know if you need more info.
EDIT
I was able to decompile the DLL using Reflector, and now have the source code and access to Microsoft Visual Studio for Applications 2.0. Incase you need me to make changed to the DLL itself.
Also I tried building it with the "make visible to com" option checked but still got the same error with regsvr 32 and regasm.