我需要通过 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/