简体   繁体   English

如何提取通过WCF应用程序中的NetworkCredentials类发送的凭据?

[英]How to extract the credentials sent through NetworkCredentials class in WCF Application?

I am working on a project where the credentials are sent from Windows mobile(Compact Framework) through the NetworkCredentials object. 我正在一个项目中,凭据是通过WindowsCredentials对象从Windows mobile(Compact Framework)发送的。 I need to extract the credentials from the Header and authenticate against the LDAP server in the WCF application. 我需要从标头中提取凭据,并针对WCF应用程序中的LDAP服务器进行身份验证。 Is there a way to do it ? 有办法吗? Any suggestions would be welcomed ! 任何建议都将受到欢迎!

You don't need to extract credentials, pass the NetworkCredential object direclty to LDAP: 您无需提取凭证,就可以将NetworkCredential对象Dirclty传递给LDAP:

public static bool login(string domain, System.Net.NetworkCredential cred)
{
    try
    {
        LdapConnection conn = new LdapConnection(domain);
        conn.Bind(cred);
        return true; 
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM