我有一個在IIS中設定WCF的任務,需要控制不同用戶對不同端點的訪問。 我能夠設定HTTPS。當我試圖在IIS中用標簽<location>來設定權限時,似乎沒有用。
我有兩個用戶名,一個是xxx.luo,另一個是xxx.luo2。 我希望Service1.csv只能被xxx.luo訪問,Service2.svc只能被xxx.luo2訪問。但在下面的配置中,我只能讓xxx.luo訪問這兩個端點。
對于xxx.luo2,我總是得到以下錯誤資訊:
對于xxx.luo2,我總是得到以下錯誤資訊:
"HTTP請求未經授權,客戶認證方案為'協商'。從服務器收到的認證頭是'Negotiate,NTLM'。遠程服務器回傳了一個錯誤。(401) Unauthorized."
你有什么建議嗎?是否可以通過這種方式來控制權限?
<?xml version="1.0" encoding="UTF-8"? >
<configuration>/span>
<appSettings>/span>
<add key="aspnet: UseTaskFriendlySynchronizationContext" value="true" <>
</appSettings>
<system.web>/span>
<compilation debug="true" targetFramework="4. 6.1" />
<httpRuntime targetFramework="4.6.1"/span> />
</system.web>
<system.serviceModel>/span>
<bindings>/span>
<basicHttpBinding>/span>
<binding name="secureHttpBinding"/span>>
<security mode="Transport">/span>
<transport clientCredentialType="Windows" />
</security>
</binding>/span>
</basicHttpBinding>/span>
</bindings>/span>
<services>/span>
<service name="WcfService1.Service1">
< endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="WcfService1. IService1" />。
< endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
<service name="WcfService1.Service2">
< endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="WcfService1. IService2" />。
< endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>/span>
<behaviors>>
<serviceBehaviors>/span>
<behavior>/span>
<serviceMetadata httpsGetEnabled="true"/span> />
<serviceDebug includeExceptionDetailInFaults="false"/span> />/span>
</behavior>
</serviceBehaviors>/span>
</behaviors>/span>
< serviceHostingEnvironment aspNetCompatibilityEnabled="true"/span> multipleSiteBindingsEnabled="true"/span> />
</system.serviceModel>
<system.webServer>/span>
<modules runAllManagedModulesForAllRequests="true"/span> />
<security>
<authentication>>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true"/>
</authentication>/span>
<授權>/span>
< remove users="*" roles=" verbs=" />
<add accessType="allow" roles="xxx。 luo"/>
</授權>
</security>/span>
</system.webServer>/span>
<location path="默認網站/Service2. svc" allowOverride="false" inheritInChildApplications="false">
<system.webServer>/span>
<security>/span>
<authentication>>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true"/>
</authentication>/span>
<授權>/span>
< remove users="*" roles=" verbs=" />
<add accessType="allow" roles="xxx。 luo2"/>
</授權>
</security>/span>
</system.webServer>/span>
</location>
</configuration>/span>
uj5u.com熱心網友回復:
在一個已經有很多stackoverflow聲譽的同事的幫助下,我(他)想出了解決方案。
- 我需要在標簽
<system.webServer>中設定我的用戶名xxx.luo和xxx.luo2都可以訪問兩個頁面。
- 在標簽
<location>中的Service1.svc頁面,我洗掉了xxx.luo2的訪問權限 。
- 在標簽
<location>中,對于Service2.svc頁,我洗掉了xxx.luo的訪問權限 。
web.config的內容如下:
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/316157.html
標籤:
上一篇:引數型別為`constT&`的復制建構式和型別為`constT<U>&`的復制建構式之間有什么區別嗎?
下一篇:如何在jinja2中匯入變數
