好吧,我已经解决了几乎所有的问题,PHP 手册,并在整个互联网上发布了这个问题。似乎没有任何帮助。
我正在开展一个项目,该项目需要我在 Active Directory 上对组织中的不同用户进行身份验证(或至少能够查找 UID)。对于连接和身份验证,他们为我提供了一个具有身份验证所需功能的 dll 文件。我需要使用这个 dll 文件和其中的函数来让我的应用程序正常工作。
以下是我迄今为止尝试过的不同方法以及每种方法的错误。
我试过用
dl('filename.dll');
得到了错误
Call to undefined function dl() in C:\xampp\htdocs\OOP_curater\index.php on line 16
环顾四周后,我发现了 this和 this我意识到它不再受支持。
然后我尝试将 dll 放在 C:\xampp\php\ext 中并向 php.ini 添加一个扩展行。 (只是为了它)重新启动 php 给了我一条错误消息,说它不是一个有效的 PHP 扩展。
然后我尝试使用
$action = new COM("ProjectName.FunctionName") or die ("Could not initialise MS Word object.");
出现如下错误
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
环顾四周让我找到了类似于 this 的链接.我意识到我需要注册 DLL,所以尝试了
regsvr32 C:\xampp\htdocs\OOP_curater\filename.dll
得到了错误
DllRegisterServer entry point was not found
然后我尝试了
regsvr32 /i /n C:\xampp\htdocs\OOP_curater\filename.dll
并出现“未找到 DLL 安装”错误。
我必须承认,我仍然不确定我是否正确理解了 (Projectname.FunctionName) 部分,我真的无法理解围绕该主题的大部分文档。
然后我尝试了下面的代码
$comobj = new DOTNET("projectname", "projectname.function");
得到这个错误
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
我现在有以下关于为 PHP 加载 DLL 的问题
加载 DLL 的最佳方式是什么:
一个。它不是真正的 PHP 函数
来源不可用
无法注册(假设由于上述错误)
它不能被重新编译为 PHP 扩展/可注册
注意事项
我对 .net 和 Active Directory 知之甚少,这就是为什么我觉得这更难处理。另外考虑到问题的长度,希望我没有错过任何重要的事情。如果您需要更多信息,请告诉我。
编辑
我能够使用 Reflector 反编译 DLL ,现在拥有源代码并可以访问 Microsoft Visual Studio for Applications 2.0。如果您需要我对 DLL 本身进行更改。
我还尝试在选中“使 com 可见”选项的情况下构建它,但在使用 regsvr 32 和 regasm 时仍然出现相同的错误。
最佳答案
这并没有直接回答所问的问题,而是解决了您的问题。
在 php 中使用 adLDAP ( http://adldap.sourceforge.net/ ) 它会为您完成所有工作。您不需要外部 DLL 或自己编写。
示例:
$adldap = new adLDAP();
$aUserInfo = getLDAPUserInfo($adldap, $username);
if ($aUserInfo) {
if (strlen($aUserInfo['mail']) > 0) {
$email = $aUserInfo['mail'];
if ($email) {
$userRow['email'] = $email;
}
}
}
或
$adldap = new adLDAP();
$authUser = $adldap->user()->authenticate($username, $password);
if ($authUser == true) {
if ($adldap->user()->inGroup($username,'ServerAdmins')) {
// This user is in server admins
}
}
关于php - 在 PHP 的 DLL(.net) 中运行函数 - 似乎没有任何效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28985292/
作为我的Rails应用程序的一部分,我编写了一个小导入程序,它从我们的LDAP系统中吸取数据并将其塞入一个用户表中。不幸的是,与LDAP相关的代码在遍历我们的32K用户时泄漏了大量内存,我一直无法弄清楚如何解决这个问题。这个问题似乎在某种程度上与LDAP库有关,因为当我删除对LDAP内容的调用时,内存使用情况会很好地稳定下来。此外,不断增加的对象是Net::BER::BerIdentifiedString和Net::BER::BerIdentifiedArray,它们都是LDAP库的一部分。当我运行导入时,内存使用量最终达到超过1GB的峰值。如果问题存在,我需要找到一些方法来更正我的代
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
是的,我知道最好使用webmock,但我想知道如何在RSpec中模拟此方法:defmethod_to_testurl=URI.parseurireq=Net::HTTP::Post.newurl.pathres=Net::HTTP.start(url.host,url.port)do|http|http.requestreq,foo:1endresend这是RSpec:let(:uri){'http://example.com'}specify'HTTPcall'dohttp=mock:httpNet::HTTP.stub!(:start).and_yieldhttphttp.shou
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我正在尝试用ruby中的gsub函数替换字符串中的某些单词,但有时效果很好,在某些情况下会出现此错误?这种格式有什么问题吗NoMethodError(undefinedmethod`gsub!'fornil:NilClass):模型.rbclassTest"replacethisID1",WAY=>"replacethisID2andID3",DELTA=>"replacethisID4"}end另一个模型.rbclassCheck 最佳答案 啊,我找到了!gsub!是一个非常奇怪的方法。首先,它替换了字符串,所以它实际上修改了
我有一些代码在几个不同的位置之一运行:作为具有调试输出的命令行工具,作为不接受任何输出的更大程序的一部分,以及在Rails环境中。有时我需要根据代码的位置对代码进行细微的更改,我意识到以下样式似乎可行:print"Testingnestedfunctionsdefined\n"CLI=trueifCLIdeftest_printprint"CommandLineVersion\n"endelsedeftest_printprint"ReleaseVersion\n"endendtest_print()这导致:TestingnestedfunctionsdefinedCommandLin
我正在处理旧代码的一部分。beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)endRubocop错误如下:Avoidstubbingusing'allow_any_instance_of'我读到了RuboCop::RSpec:AnyInstance我试着像下面那样改变它。由此beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)end对此:let(:sport_