私たちは、ライトスイッチを備えたイントラネット用の一連のアプリケーションを開発しました。それらはすべて Windows 認証を使用して実行されますが、匿名接続を許可する必要がある (LS アプリケーションでホストされる) いくつかの wcf サービスを開発する必要があります。
これは、公開されているサービスの現在の web.config 設定です。
<system.web>
<authentication mode="Windows">
<forms name="Main" />
</authentication>
<identity impersonate="true" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="metadataSupport" name="LightSwitchApplication.WCF.HelperService">
<endpoint address="" binding="customBinding" bindingConfiguration="LightSwitchApplication.WCF.HelperService.customBinding0" contract="LightSwitchApplication.WCF.HelperService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<customBinding>
<binding name="LightSwitchApplication.WCF.HelperService.customBinding0">
<binaryMessageEncoding />
<httpTransport authenticationScheme="Anonymous" />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
こことmsdnを掘り下げた後、この動作に到達する方法があるかどうかはまだわかりません。
Windows 資格情報を使用してこれらのサービスにアクセスすると、すべてが正常に機能します。匿名認証でサービスを使用する方法が見つかりませんでした。この装飾をサービスに追加して、バインディングモードを変更しようとしました:
[ServiceContract(Namespace="")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[AllowAnonymous]
[SecurityPermission(SecurityAction.Assert)]
[OverrideAuthentication()]
[Authorize(Users="*")]
[OverrideAuthorization()]
public class HelperService
{
...
}
また、web.config でタグを使用して、WCF フォルダーをメイン フォルダーの下のアプリケーションとして設定しようとしましたが、この場合は問題が異なり、コンパイル パスと dll ディレクトリ パスに関連しています。私はそれを解決しようとしました:
<location path="WCF">
<system.web>
<authentication mode="None" />
<compilation>
<codeSubDirectories>
<add directoryName="../bin"/>
</codeSubDirectories>
</compilation>
</location>
しかし、IIS がまだアセンブリを見つけられないため、エラーが発生します。システムは、指定されたファイルを見つけることができません。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.LightSwitch.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.LightSwitch.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.
=== Pre-bind state information ===
LOG: User = IIS APPPOOL\DefaultAppPool
LOG: DisplayName = Microsoft.LightSwitch.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/MyApp/WCF/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\MyApp\WCF\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\WCF\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.LightSwitch.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp_wcf/88e6cc1b/e1821fec/Microsoft.LightSwitch.Server.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp_wcf/88e6cc1b/e1821fec/Microsoft.LightSwitch.Server/Microsoft.LightSwitch.Server.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/WCF/bin/Microsoft.LightSwitch.Server.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/WCF/bin/Microsoft.LightSwitch.Server/Microsoft.LightSwitch.Server.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp_wcf/88e6cc1b/e1821fec/Microsoft.LightSwitch.Server.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp_wcf/88e6cc1b/e1821fec/Microsoft.LightSwitch.Server/Microsoft.LightSwitch.Server.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/WCF/bin/Microsoft.LightSwitch.Server.EXE.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/WCF/bin/Microsoft.LightSwitch.Server/Microsoft.LightSwitch.Server.EXE.
わかりました、これで問題ありません... 親フォルダーから完全な bin フォルダーを MyApp/wcf にコピーし (テストのためだけに、後で解決します)、最終的にアプリケーションが読み込まれますが、... 今は 401.2 を取得しますエラー:
Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.
また、WCF フォルダーに web.config を作成し、次の方法で匿名アクセスを許可しました。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
<authorization>
<add accessType="Allow" users="?" />
</authorization>
</security>
</system.webServer>
<system.web>
<identity impersonate="false" />
</system.web>
</configuration>
それは私を夢中にさせているので、私はそれを解決するために助けが必要です. LightSwitch アプリで定義されたすべてのビジネス ロジックを再利用したいのですが、そのような「ばかげたこと」を実行できるかどうかはまだわかりません。
これを身につける正しい方法を教えてください。
どうもありがとう。