1

0ffice365ユーザー用のパスワードリセットWebサイトがあります。バックグラウンドでPowerShellコマンドを実行して、ユーザーパスワードをリセットします。何らかの理由で、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#コードが背後にあります。

なりすましクラスを使用してみましたが、それも機能しません。

これが私のコードの一部です。

 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"/>
4

2 に答える 2

2

IISで、ApplicationPoolIdentityをLocalServiceに変更しました。これにより、公開前に正常に機能していたときに公開済みのVisualStudioWebサイトを実行する際のアクセス拒否エラーが解決されました。

于 2018-08-02T18:06:16.593 に答える
1

これは、「ダブルホップ」のID/セキュリティの問題である可能性があります。

ローカルホストで実行している場合、WindowsIDは同じマシン上で認識されます。
Webサーバーで実行する場合、少なくとももう1台のマシンが関係しています。

関連する質問は次のとおりです。IISはWebページの実行にどのIDを使用していますか。そのIDには、ネットワークを使用するためのアクセス許可がありますか?そのIDには、リモートサーバーでパスワードリセットを実行する権限がありますか?

于 2012-05-25T15:48:42.620 に答える