Authenticate user by ADFS (Active Directory Federation Service)

后端 未结 3 745
失恋的感觉
失恋的感觉 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<IYourInterface >(binding, "your service address");
    
    factory.ConfigureChannelFactory();
    
    IYourInterface channel = factory.CreateChannelWithIssuedToken(token);
    

    Hope this helps!

    0 讨论(0)
  • 2021-01-06 05:26

    The AD FS 2.0 sign-in pages support username/password authentication out of the box. No code or customizations necessary.

    0 讨论(0)
  • 2021-01-06 05:31

    As per @Marnix, this is out the box behavior.

    However, just to point out:

    Authenticating the user is NOT the same as checking whether a particular user exists in Active Directory.

    e.g. the user could be locked out. He still exists in AD but will not be able to authenticate.

    0 讨论(0)
提交回复
热议问题