IIS加载我的Isapi DLL后,该DLL中的代码是作为系统权限运行还是作为存放这个dll的目录所允许的用户权限运行?我还是举个例子说明我的问题吧。
比如:我写了一个Isapi扩展DLL名为MyDll.dll放到服务器上的c:\www\User1目录下(该目录只允许User1用户完全访问,其他用户一律不允许访问。User1用户也不是Administrators组的成员)c:\www\User1目录即为iis里面设置的主目录。当用户访问http://MyWebSite/MyDll.dll 时MyDll.dll被iis进程加载从而MyDll.dll中的代码将会被执行。我的问题是:MyDll.dll中的代码可以调用权限管理的api更改其他目录的权限吗?MyDll.dll中的代码可以读写不允许User1用户访问的文件吗?MyDll.dll是作为系统权限运行的还是作为User1用户权限运行?请熟悉winnt安全权限管理的编程高人赐教,谢谢先!!!

解决方案 »

  1.   

    By default, the ASP and ISAPI Extension DLLs use the IUSR_computer_name account, which is a member of the Guests group used for anonymous requests. You can change the IIS setting manually, or impersonate a user from Active Server Pages. By default, ISAPI Filter DLLs, not to be confused with ISAPI Extension DLLs, run in the original context of the IIS service. All services run by default under the Local System account of the machine on which they are installed. The Local System account has access to almost all resources on the local machine not specifically denied to it, and no resources on any other machines on the network. 
    Reference:
    HOW TO: Configure NTFS File Permissions for Security of ASP.NET Applications
    http://support.microsoft.com/kb/815153
    How to secure the IUSER_<Computer_name> account
    http://support.microsoft.com/kb/323640
    INFO: Security Ramifications for IIS Applications
    http://support.microsoft.com/kb/q158229
    INFO: Security Issues with Objects in ASP and ISAPI Extensions
    http://support.microsoft.com/kb/q172925/
    INFO: Difficulties Using Net APIs in ISAPI and ASP COM Objects
    http://support.microsoft.com/kb/217144
    How to impersonate a user from Active Server Pages
    http://support.microsoft.com/kb/248187
    How To Launching OLE Servers from ISAPI Extensions
    http://support.microsoft.com/kb/156223
    How To Access Network Files from IIS Applications
    http://support.microsoft.com/?id=207671
    HOW TO: Run Applications Not in the Context of the System Account in IIS
    http://support.microsoft.com/kb/319067
    INFO: WinInet Not Supported for Use in Services
    http://support.microsoft.com/kb/238425
      

  2.   

    你在代码里面直接调用GetUserName,通过OutputDebugString 输出
      

  3.   

    感谢两位前辈的指点,我确实写了一个isapi dll进行试验,用getusername输出的确实是IUSER_xxxCOMPUTERNAMExxx这个iis内置的匿名访问帐户。我想进一步知道在这种情况下如果isapi dll中的代码创建进程该进程的权限是什么,于是我又写了一个窗口程序名为test.exe进行测试。我让test.exe调用setwindowtext把该窗口的标题设置为test.exe调用getusername得到用户名。但我发现isapi dll虽然能成功创建test.exe(通过任务管理器)但test.exe确不显示任何窗口——这是什么呢?而且我用任务管理器也无法结束这个进程(terminateprocess)——这是为什么呢?isapi dll创建的这个进程使用的是什么用户权限呢?请前辈们赐教,谢谢先!
      

  4.   

    see the "Preventing USER32 Window Station/Desktop Failure" section in the article "How To Launching OLE Servers from ISAPI Extensions" mentioned above.
      

  5.   

    感谢蒋老师(蒋晟.MSMVP2004Jan)!经由这篇介绍isapi扩展dll启动ole exe server的how to问答我粗略总结出一下几点:
    1 isapi扩展dll是作为iis的内置匿名帐户IUSR_computername运行的。
    2 如果改dll内又创建其他进程该进程也是被赋予IUSR_computername用户权限。
    3 对于ole server的exe可以经由该com注册表中的对应键添加run as项,设置该ole server exe作为其他用户运行。
    4  可以调用RevertToSelf(api)将isapi扩展dll运行线程的权限由IUSR_computername转换为LocalSystem。转换以后isapi扩展dll再启动新的进程就是以LocalSystem用户运行。但以LocalSystem用户运行的进程不能访问任何网络资源。
    请前辈们评估我的以上4条是否准确?不知道这些规则在今后的winnt版本中是否有变化?谢谢!