Authenticate user by ADFS (Active Directory Federation Service)

后端 未结 3 746
失恋的感觉
失恋的感觉 2021-01-06 05:06

I need to check whether particular user exist OR not in Active Directory by ADFS.

So, I want my ADFS to check user Authentication

3条回答
  •  迷失自我
    2021-01-06 05:17

    To use Username/Password authentication you can use the

    trust/13/UsernameMixed

    endpoint of the ADFS 2.0.

    This does NOT check if the user exists in the Active Directory!

    In code you request the token like this:

    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);
    

    Then create the channel factory for your service using your token:

    var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.Message);
    
    var factory = new ChannelFactory(binding, "your service address");
    
    factory.ConfigureChannelFactory();
    
    IYourInterface channel = factory.CreateChannelWithIssuedToken(token);
    

    Hope this helps!

提交回复
热议问题