IChannelCredentials 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
一個允許在服務代理上設定特定安全特性的介面。
public interface class IChannelCredentials
[System.Runtime.InteropServices.Guid("181b448c-c17c-4b17-ac6d-06699b93198f")]
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch)]
public interface IChannelCredentials
[<System.Runtime.InteropServices.Guid("181b448c-c17c-4b17-ac6d-06699b93198f")>]
[<System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch)>]
type IChannelCredentials = interface
Public Interface IChannelCredentials
- 屬性
範例
monString = "service:mexAddress=http://localhost:8000/ServiceModelSamples/Service?wsdl"
monString = monString + ", address=http://localhost:8000/ServiceModelSamples/Service"
monString = monString + ", binding=BasicHttpBinding_ICalculator, bindingNamespace=http://Microsoft.ServiceModel.Samples"
monString = monString + ", contract=ICalculator, contractNamespace=http://Microsoft.ServiceModel.Samples"
Set monikerProxy = GetObject(monString)
'Set the Service Certificate.
monikerProxy.ChannelCredentials.SetServiceCertificateAuthentication "CurrentUser", "NoCheck", "PeerOrChainTrust"
monikerProxy.ChannelCredentials.SetDefaultServiceCertificateFromStore "CurrentUser", "TrustedPeople", "FindBySubjectName", "localhost"
'Set the Client Certificate.
monikerProxy.ChannelCredentials.SetClientCertificateFromStoreByName "CN=client.com", "CurrentUser", "My"
MsgBox monikerProxy.Add(3, 4)
備註
非管理用戶端使用「服務」名稱來存取 Windows Communication Foundation(WCF)服務。 這些用戶端受 WCF 安全模型約束,而非 COM 安全模型。 IChannelCredentials介面用於指定通道憑證。 這是必要的,因為 COM 名稱無法存取受管理的 WCF 安全物件模型。
通道建立後,呼叫介面上的方法 IChannelCredentials 是不合法的。 這是因為 Windows Communication Foundation(WCF)不支援在已開啟的通道上更改安全設定。 當服務名稱用戶端取得代理權時,該頻道尚未建立。 因此,用戶端必須先呼叫 IChannelCredentials 方法,才能呼叫服務方法。 如果客戶端在呼叫服務方法後呼叫該 IChannelCredentials 方法,則會拋出例外RPC_E_TOO_LATE。
方法
| 名稱 | Description |
|---|---|
| SetClientCertificateFromFile(String, String, String) |
從檔案中取得憑證並加入用戶端憑證。 |
| SetClientCertificateFromStore(String, String, String, Object) |
從憑證儲存庫取得憑證並加入用戶端憑證。 |
| SetClientCertificateFromStoreByName(String, String, String) |
從憑證儲存庫以名稱檢索憑證,並將其加入用戶端憑證。 |
| SetDefaultServiceCertificateFromFile(String, String, String) |
從檔案中擷取憑證,並將其作為預設憑證加入服務憑證。 |
| SetDefaultServiceCertificateFromStore(String, String, String, Object) |
從憑證儲存庫取得憑證,並將其作為預設憑證加入服務憑證。 |
| SetDefaultServiceCertificateFromStoreByName(String, String, String) |
從憑證庫以名稱檢索憑證,並將其作為預設憑證加入服務憑證。 |
| SetIssuedToken(String, String, String) |
設定已發行代幣的參數。 |
| SetServiceCertificateAuthentication(String, String, String) |
設定服務憑證認證參數。 |
| SetUserNameCredential(String, String) |
設定使用者名稱憑證。 |
| SetWindowsCredential(String, String, String, Int32, Boolean) |
設定 Windows 的憑證。 |