WCF proxy and userPrincipalName

We have a fairly large application that my team and I are developing, which contains several services based on WCF NetTCP. The Windows service in which this system will work will not be a local account, but instead a standard domain user (with administrator rights on the servers serving this service). In the middle of testing connectivity, I ran into a problem when SSPI causes a failure. Based on several hours of research, this led me to skip the following line from my client configuration:

<identity>
     <userPrincipalName value="MACHINE\user" />
</identity>

The problem with this is that I do not use VS or svcutil to create a client / proxy for this service - the proxies used are completely written in the code and inherit System.ServiceModel.ClientBase. I believe that the original reason this option was chosen was that we could use the same DataMember objects that pass through the services on either side of the fence - third-party groups will not need to connect to our services, so It's not a problem.

Does anyone know how I can set userPrincipalName in the client (code or via configuration) when I do not have the endpoints specified in the standard system.serviceModel configuration section?

Here my client web.config looks like a link:

    <system.serviceModel>
    <diagnostics>
        <messageLogging logEntireMessage="true" logMalformedMessages="true"
         logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
    <behaviors>
        <serviceBehaviors>
            <behavior name="includeExceptions">
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <netTcpBinding>
            <binding name="NetTcpBinding_Default" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="Infinite" sendTimeout="01:00:00" portSharingEnabled="true" transferMode="Buffered" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
                </security>
            </binding>
        </netTcpBinding>
    </bindings>

</system.serviceModel>
+3
2

; -, ClientBase, ClientBase, .

, , , , EndpointIdentity EndpointAddress, . - :

EndpointIdentity epid = EndpointIdentity.CreateUpnIdentity("user@domain.fqdn");
EndpointAddress epaddr = new EndpointAddress(uri, epid);

MyClient client = new MyClient(epaddr);
+6

, , , , . , , - svcutil, dll, datamember as/r

svcutil http://localhost/service/service.svc /r:AssemblyThatHasDataMembers.dll /out:ServiceProxy.cs

datamember ServiceProxy.cs. , wsdl/xsd ( ), /ct ..

, -, , , , .

+1

Source: https://habr.com/ru/post/1714446/


All Articles