Επεξεργασία

Κοινή χρήση μέσω


IChannelCredentials Interface

Definition

An interface that allows the setting of certain security features on a service proxy.

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
Attributes

Examples

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)  

Remarks

Unmanaged clients use the "service" moniker to access Windows Communication Foundation (WCF) services. These clients are subject to the WCF security model rather than the COM security model. The IChannelCredentials interface is provided to specify channel credentials. This is required because the COM moniker cannot access the managed WCF security object model.

It is not legal to call methods on the IChannelCredentials interface after the channel is created. This is because Windows Communication Foundation (WCF) does not support changing security settings on an already opened channel. When the service moniker client obtains a proxy, the channel is not yet created. Thus, the client must call IChannelCredentials methods prior to invoking the service method. If the client calls an IChannelCredentials method after the service method is invoked, the exception RPC_E_TOO_LATE is thrown.

Methods

SetClientCertificateFromFile(String, String, String)

Retrieves a certificate from a file and adds it to the client credentials.

SetClientCertificateFromStore(String, String, String, Object)

Retrieves a certificate from a certificate store and adds it to the client credentials.

SetClientCertificateFromStoreByName(String, String, String)

Retrieves a certificate from a certificate store by name and adds it to the client credentials.

SetDefaultServiceCertificateFromFile(String, String, String)

Retrieves a certificate from a file and adds it to the service credentials as the default certificate.

SetDefaultServiceCertificateFromStore(String, String, String, Object)

Retrieves a certificate from a certificate store and adds it to the service credentials as the default certificate.

SetDefaultServiceCertificateFromStoreByName(String, String, String)

Retrieves a certificate from a certificate store by name and adds it to the service credentials as the default certificate.

SetIssuedToken(String, String, String)

Sets parameters for the issued token.

SetServiceCertificateAuthentication(String, String, String)

Sets the service certificate authentication parameters.

SetUserNameCredential(String, String)

Sets the user name credentials.

SetWindowsCredential(String, String, String, Int32, Boolean)

Sets the Windows credentials.

Applies to