Guest User

Untitled

a guest
May 31st, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. factory.Credentials.UserName.UserName = "bob";
  2. factory.Credentials.UserName.Password = "abc!123";
  3.  
  4. // create token request
  5. var rst = new RequestSecurityToken
  6. {
  7. RequestType = RequestTypes.Issue,
  8. KeyType = KeyTypes.Symmetric,
  9. AppliesTo = new EndpointReference(_serviceAddress.AbsoluteUri)
  10. };
  11.  
  12. private GenericXmlSecurityToken NewGetAdfsSamlTokenWinAuth()
  13. {
  14. try
  15. {
  16. WS2007HttpBinding binding = new WS2007HttpBinding(SecurityMode.Transport);
  17. binding.Security.Message.EstablishSecurityContext = false;
  18. binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
  19. WSTrustChannelFactory factory = new WSTrustChannelFactory((binding), new EndpointAddress(this.adfsIntegratedAuthUrl));
  20. factory.TrustVersion = TrustVersion.WSTrustFeb2005;
  21. factory.Credentials.SupportInteractive = false;
  22. var rst = new RequestSecurityToken
  23. {
  24. RequestType = RequestTypes.Issue,
  25. AppliesTo = new EndpointReference("urn:federation:MicrosoftOnline"),
  26. KeyType = KeyTypes.Bearer
  27. };
  28. IWSTrustChannelContract channel = factory.CreateChannel();
  29. return channel.Issue(rst) as GenericXmlSecurityToken;
  30. }
  31. catch (Exception ex)
  32. {
  33. // Do something with the exception
  34. }
  35. return null;
  36. }
Add Comment
Please, Sign In to add comment