无法从IIS

时间:2015-09-21 20:39:46

标签: c# security iis process processstartinfo

我面临的问题是:

我正在尝试使用Process从我的C#WebApplication启动AcrobatReader。

https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx

当我在IIS Express中运行应用程序(在我的默认用户帐户下运行)时,一切正常,我可以在Acrobat Reader上打开我想要的文件。

相反,当我尝试在IIS上部署(在IIS APPPOOL \ xxx下运行)时,该进程无法启动AcrobatReader。

我已经尝试将AcrobatReader的权限分配给IIS_IUSRS以及IIS APPPOOL \ xxx,但没有任何更改

还尝试将IIS APPPOOL \ xxx添加到管理员组但没有运气

`      `ProcessStartInfo info = new ProcessStartInfo();
        info.FileName = Constants.ACROBAT_READER_PATH;
        info.Arguments = args;
        info.Verb = "Printto";
        info.CreateNoWindow = true;
        info.WindowStyle = ProcessWindowStyle.Hidden;
        info.UseShellExecute = false;

        info.Domain = Environment.MachineName;
        info.UserName = "AdminUser";
        string password = "AdminPassword";
        System.Security.SecureString securePassword = new System.Security.SecureString();

        foreach (char c in password)
            securePassword.AppendChar(c);

        info.Password = securePassword;

        try
        {

            //The following security adjustments are necessary to give the new 
            //process sufficient permission to run in the service's window station
            //and desktop. This uses classes from the AsproLock library also from 
            //Asprosys.
            IntPtr hWinSta = GetProcessWindowStation();
            WindowStationSecurity ws = new WindowStationSecurity(hWinSta,
              System.Security.AccessControl.AccessControlSections.Access);
            ws.AddAccessRule(new WindowStationAccessRule("AdminUser",
                WindowStationRights.AllAccess, System.Security.AccessControl.AccessControlType.Allow));
            ws.AcceptChanges();

            IntPtr hDesk = GetThreadDesktop(GetCurrentThreadId());
            DesktopSecurity ds = new DesktopSecurity(hDesk,
                System.Security.AccessControl.AccessControlSections.Access);
            ds.AddAccessRule(new DesktopAccessRule("AdminUser",
                DesktopRights.AllAccess, System.Security.AccessControl.AccessControlType.Allow));
            ds.AcceptChanges();

            using (Process process = Process.Start(info))
            {
            }
        }
        catch (Exception ex)
        {
        }

感谢您的时间

0 个答案:

没有答案