none
WCF模拟总是提示不能登陆 RRS feed

  • 问题

  • Hi 付老师。我在测试您的lesson10中的Impersonation这个例子时总是提示异常:

    Code Snippet

    System.ServiceModel.Security.SecurityNegotiationException: The server has rejected the client credentials. ---> System.Security.Authentication.InvalidCredentialException: The server has rejected the client credentials. ---> System.ComponentModel.Win32Exception: 登录没有成功
       --- End of inner exception stack trace ---
       at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
       at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
       at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade(Stream stream, SecurityMessageProperty& remoteSecurity)
       --- End of inner exception stack trace ---



    我在系统中创建了一个用户wcf,用户密码wcf.  然后代码为:

    Code Snippet

                NetworkCredential m_creds =  new NetworkCredential("wcf", "wcf");
                try
                {
                    m_proxy = new localhost.ImpersonationServiceClient();
                    m_proxy.ClientCredentials.Windows.ClientCredential = m_creds;
                    m_proxy.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
                    m_proxy.ImpersonationAllowed();
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }


    我遗漏了什么东西吗?




    2008年5月25日 3:43

答案