ログインしている Windows ユーザーを WCF サービスで取得しようとしています。ServiceSecurityContext を使用してみましたが、Current は常に null です。
ServiceSecurityContext.Current.WindowsIdentity.Name
また、OperationContext を使用してみました。この場合、ServiceSecurityContext は null を返します。
OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name
これが私のweb.configです:
<bindings>
<basicHttpBinding>
<binding name="HttpWindowsBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
また
<authentication mode="Windows"/>
誰かが私が間違っていることを見ることができますか?
更新: ServiceSecurityContext を機能させる試みを断念しました。最後に、aspNetCompatibilityEnabled="true" を設定することで解決策を見つけました。
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
また、サービス クラスに次の属性を追加しました。
[System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode = System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)]
これにより、次の方法でWindowsユーザーを取得できました。
HttpContext.Current.User.Identity.Name