English 中文(简体)
使用 IIS 网络服务器上的电壳时被拒绝访问
原标题:Access denied when using powershell on IIS webserver

我为 0ffice 365 用户的 0ffice 365 用户有一个密码重设网站。 它在背景中运行电壳命令, 以重置用户密码。 出于某种原因, 当我使用 VS, 我用它的页面运行浏览器时, 它的工作效果很好 。 但是当我从现场网站运行时, 我得到了这个错误 。

Processing data from remote server failed with the following error message: Access is denied. For more information, see the about_Remote_Troubleshooting Help topic. 

该页面是aspx.net, C# 代码后面的 aspx.net 。

我试过使用模仿者课,但是也没用。

这是我的一些代码。

 using (new Impersonator("user", "domain", "pass"))
    {

        PSCredential creds = new PSCredential("office365email", "password");

        WSManConnectionInfo connectionInfo = new WSManConnectionInfo(
            new Uri("https://server.outlook.com/PowerShell-LiveID?PSVersion=2.0"),
            "http://schemas.microsoft.com/powershell/Microsoft.Exchange", creds);
        connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;



        Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);

        runspace.ApartmentState = System.Threading.ApartmentState.STA;
        runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;

        try
        {


            runspace.Open();


            pipeline = runspace.CreatePipeline();

            Command forwardcommand = new Command("Set-Mailbox");
            forwardcommand.Parameters.Add("Identity", user);
            forwardcommand.Parameters.Add("Password", pass);




            pipeline.Commands.Add(forwardcommand);

            try
            {
                pipeline.Invoke();



                runspace.Close();
                pipeline.Stop();
                return "Password Successfully Changed";



            }
            catch (Exception er)
            {
                runspace.Close();
                pipeline.Stop();

                return er.Message;


            }
        }
        catch (PSRemotingTransportException eer)
        {

            runspace.Close();


            return eer.Message;// "Server busy please try again later";
        }
    }

为何我无法在网站上做,

<authentication mode="Windows"/>
    <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
        <providers>
            <clear/>
            <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
            <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>
        </providers>
    </roleManager>
    <identity impersonate="true"/>
最佳回答

这可能是一个“双跳”身份/安全问题。

When running on localhost, the Windows identity is known on the same machine.
When running on the web server, there is at least one more machine involved.

相关问题包括: 运行网页时, IIS 使用什么身份? 该身份是否允许使用网络? 该身份是否允许在远程服务器上执行密码重设?

问题回答

在《国际统计学会一》中,I改变了当地服务应用程序PoolIity。这解决了在运行已出版的视觉演播室网站时被拒绝访问的错误,因为该网站在出版前工作良好。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签