c# - 通过 ADFS(Active Directory 联合身份验证服务)对用户进行身份验证

标签 c# .net c#-4.0 adfs2.0

我需要通过 ADFS 检查特定用户是否存在于 Active Directory 中。

所以,我希望我的 ADFS 检查用户身份验证通过用户名/密码。

谁能提供相同的示例代码或教程。

提前致谢!

最佳答案

要使用用户名/密码身份验证,您可以使用

trust/13/UsernameMixed

ADFS 2.0 的端点。

这不会检查用户是否存在于 Active Directory 中!

在代码中,您可以像这样请求 token :

WSTrustChannelFactory adfsfactory = new WSTrustChannelFactory(new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential),
                            StsEndpoint);

adfsfactory.TrustVersion = TrustVersion.WSTrust13;

// Username and Password here...
factory.Credentials.UserName.UserName = "domain\username";
factory.Credentials.UserName.Password = "password";

IWSTrustChannelContract channel = adfsfactory.CreateChannel();

// request the token
SecurityToken token = channel.Issue(rst);

然后使用您的 token 为您的服务创建 channel 工厂:

var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.Message);

var factory = new ChannelFactory<IYourInterface >(binding, "your service address");

factory.ConfigureChannelFactory();

IYourInterface channel = factory.CreateChannelWithIssuedToken(token);

希望这对您有所帮助!

关于c# - 通过 ADFS(Active Directory 联合身份验证服务)对用户进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10651304/

相关文章:

c# - 在开发中使用 Azure Redis 缓存(预览版)

c# - ListView - 如何响应双击非项目?

c# - 使用 XmlSerializer 时如何向 XML 文件写入注释?

c# - PLINQ 的性能比通常的 LINQ 差

c#-4.0 - 缩短此 if 条件

c# - 寻找 C# 代码解析器

c# - WPF 组合框数据绑定(bind)所选项目

.net - 在哪里可以找到 Office open xml 完整引用?

.net - VB.NET:获取实例的类名

wpf - MVVM Batch Job处理文件属于ViewModel吗?