2012-01-09 10 views
8

के रूप में मैं विन-फॉर्म एप्लिकेशन के साथ अपनी डब्ल्यूसीएफ सेवा से कनेक्ट करने में सक्षम हूं, हालांकि मैं अपनी विंडोज सेवा के साथ ऐसा करने में सक्षम नहीं हूं। System.Security.Authentication.InvalidCredentialException: सर्वर ग्राहक साख को अस्वीकार कर दिया गया है जब भी मैं खुले आग() प्रॉक्सी के लिए यह निम्न त्रुटिसर्वर ने ग्राहक सेवा को अस्वीकार कर दिया है, डब्ल्यूसीएफ विंडोज सेवा

सर्वर क्लाइंट साख

इनर अपवाद को अस्वीकार कर दिया गया है फेंकता ।
---> System.ComponentModel.Win32Exception: लॉगऑन प्रयास विफल
--- भीतरी अपवाद स्टैक ट्रेस की समाप्ति --- System.Net.Security.NegoState.ProcessAuthentication पर
(LazyAsyncResult lazyResult)
पर System.Net.Security.NegotiateStream.AuthenticateAsClient (NetworkCredential क्रेडेंशियल, ChannelBinding बंधन, स्ट्रिंग टार्गेटनाम, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
System.Net.Security.NegotiateStream.AuthenticateAsClient (NetworkCredential क्रेडेंशियल, स्ट्रिंग टार्गेटनाम पर, रक्षा ionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade पर (स्ट्रीम धारा, SecurityMessageProperty & remoteSecurity)

की कोशिश की समाधान के लिए खोज, लेकिन कोई भी मेरी आवश्यकताओं फिटिंग, इसलिए की तैनाती।

कृपया मदद ...

अद्यतन 1:।

@ A.R, की कोशिश की का उपयोग कर

client.ClientCredentials.Windows.AllowedImpersonationLevel = 
    System.Security.Principal.TokenImpersonationLevel.Impersonation; 

लेकिन कोई लाभ नहीं हुआ।

अद्यतन 2:

WCF सेवा विन्यास

<system.serviceModel> 
    <diagnostics performanceCounters="All" /> 
    <bindings> 
     <netTcpBinding> 
     <binding name="myBindingForLargeData" maxReceivedMessageSize="5242880" maxConnections="10"> 
      <readerQuotas maxDepth="64" maxStringContentLength="5242880" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="WCFService.ServiceBehavior" 
     name="WCFService.CollectorService"> 
     <endpoint address="" binding="netTcpBinding" bindingConfiguration="myBindingForLargeData" 
      name="netTcpEndPoint" contract="WCFService.ICollectorService" /> 
     <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" 
      name="mexTcpEndPoint" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:8010/WCFService.CollectorService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WCFService.ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="False"/> 
      <serviceDebug includeExceptionDetailInFaults="True" /> 
      <serviceThrottling 
      maxConcurrentCalls="32" 
      maxConcurrentSessions="32" 
      maxConcurrentInstances="32" 
      /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

उत्तर

4

आपकी सभी मदद के लिए धन्यवाद। मुझे कुछ शोध और परीक्षण एन त्रुटि विधि के कुछ दिनों के बाद जवाब मिला :) अच्छी तरह से मुझे पता है कि मुझे जवाब पोस्ट करने में देर हो चुकी है, लेकिन मुझे लगता है कि यह कभी भी देर से बेहतर नहीं है।

तो यहाँ समाधान

मैं नीचे के रूप में

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="netTcpEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="5242880" maxBufferSize="5242880" maxConnections="15" maxReceivedMessageSize="5242880"> 
      <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> 
     <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <client> 
     <endpoint address="net.tcp://xx.xx.xx.xx:8010/WCFService.CollectorService/" binding="netTcpBinding" bindingConfiguration="netTcpEndPoint" contract="CloudAdapter.CloudCollectorService.ICollectorService" name="netTcpEndPoint"> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

दिखाया मेरी विन्यास फाइल में कुछ परिवर्तन (दोनों ग्राहक & सर्वर)

ग्राहक के पक्ष मैं <security> टैग जोड़ा पर करना था है और सर्वर पक्ष (डब्ल्यूसीएफ सेवा विन्यास) पर एक ही टैग भी जोड़ा, जैसा कि नीचे दिखाया गया है

<bindings> 
    <netTcpBinding> 
    <binding name="myBindingForLargeData" maxReceivedMessageSize="5242880" maxConnections="10"> 
     <readerQuotas maxDepth="64" maxStringContentLength="5242880" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
     <security mode="Transport"> 
     <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
     <message clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    </netTcpBinding> 
</bindings> 

आशा इस मदद की जरूरत है :) में एक व्यक्ति

तो कुंजी <security> टैग क्लाइंट और सर्वर विन्यास फाइल पर एक ही बनाना है।

4

असल में क्या हो रहा है कि आपके कॉलिंग सेवा उचित संदर्भ सामग्री नहीं है, जैसे आप के लिए होता है जब WinForms से फोन कर रहा है। आपको कुछ प्रतिरूपण की आवश्यकता है। यह थोड़ा सा सेट अप लेता है, और यह कष्टप्रद है, लेकिन यह काम करेगा।

सौभाग्य से एमएसडीएन की एक अच्छी छोटी पैदल यात्रा है।
http://msdn.microsoft.com/en-us/library/ms731090.aspx

विषय यहाँ पर कुछ अधिक सामान्य जानकारी है:
http://msdn.microsoft.com/en-us/library/ms730088.aspx

अद्यतन:
स्थापना प्रतिरूपण झंडे पर्याप्त नहीं है। आपको इसे काम करने के लिए वास्तव में एक प्रमाण पत्र का प्रतिरूपण करना होगा।उदाहरण के लिए:

// Let's assume that this code is run inside of the calling service. 
    var winIdentity = ServiceSecurityContext.Current.WindowsIdentity; 
    using (var impContext = winIdentity.Impersonate()) 
    { 
    // So this would be the service call that is failing otherwise. 
    return MyService.MyServiceCall(); 
    } 
+0

प्रश्न अपडेट किया गया कृपया – Bravo

+0

ठीक है, आपको वास्तव में यह कहना है कि इसका प्रतिरूपण करना है। आप केवल ध्वज सेट नहीं कर सकते हैं और उम्मीद करते हैं कि यह किसी के जादुई रूप से प्रतिरूपण करे। दूसरे लिंक में प्रस्तुत सामग्री पढ़ें। –

1

आपके डब्ल्यूसीएफ सेवा पर प्रमाणीकरण मोड का उपयोग क्या कर रहा है? ऐसा लगता है कि Winform ऐप चल रहा है और सही प्रमाण-पत्र प्रदान करता है जबकि आपकी विंडोज सेवा निर्दिष्ट विशेषाधिकारों के साथ नहीं चल रही है या पास किए गए प्रमाण-पत्र वैध नहीं हैं। जब आप Winforms बनाम Windwos सेवा बनाते हैं और अंतर देखते हैं तो फिडलर का उपयोग करके अपने अनुरोध का निरीक्षण करने का प्रयास करें।

+0

मैंने अपनी विंडोज सेवा डीबग करने का प्रयास किया है, और जब मैं सेवा क्लाइंट से कनेक्शन खोलने का प्रयास करता हूं तो उपर्युक्त त्रुटि पाई। बीटीडब्ल्यू फिडलर क्या है और यह मेरे परिदृश्य में सहायक है, जहां मेरे पास net.tcp बाध्यकारी के साथ डब्ल्यूसीएफ सेवा है। कृपया मुझे बताएं – Bravo

+0

मैंने डब्ल्यूसीएफ सेवा पर किसी भी सुरक्षा को लागू नहीं किया है। एक डिफ़ॉल्ट सुरक्षा कार्यान्वयन हो सकता है। – Bravo

+0

@ ब्रेवो: फिडलर एक ऐसा उपकरण है जो नेटवर्क पर आपके आने वाले और जाने-माने ट्रैफ़िक का निरीक्षण करता है। सेवा के ऊपर विन्यास से net.Tcp का उपयोग करता है। क्या मुझे पता चलेगा कि आईआईएस या स्वयं में होस्ट किया गया है या नहीं? एक अलग मशीन पर भी आपकी विंडोज़ सेवा है? – Rajesh

1

इस पोस्ट पर मेरा उत्तर देखें The server has rejected the client credentials

सुरक्षा नोड पर ध्यान दें।

<bindings> 
    <netTcpBinding> 
    <binding name="customTcpBinding" maxReceivedMessageSize="20480000" transferMode="Streamed" > 
     <security mode="None"></security> 
    </binding> 
    </netTcpBinding> 
</bindings> 
+1

यह मेरे लिए काम किया –

संबंधित मुद्दे