Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //string endpointUri = string.Format("https://{0}/adfs/services/trust/13/usernamemixed", _serverName);
- string endpointUri = string.Format("https://{0}/adfs/services/trust/2005/usernamemixed", _serverName);
- var factory = new WSTrustChannelFactory(
- new UserNameWSTrustBinding(),
- new EndpointAddress(endpointUri));
- //factory.TrustVersion = TrustVersion.WSTrust13;
- factory.TrustVersion = TrustVersion.WSTrustFeb2005;
- if (factory.Credentials != null)
- {
- factory.Credentials.UserName.UserName = _userName;
- factory.Credentials.UserName.Password = _password;
- }
- var rst = new RequestSecurityToken
- {
- RequestType = RequestTypes.Issue,
- KeyType = KeyTypes.Bearer,
- AppliesTo = new EndpointReference(_relyingPartyUri),
- KeySizeInBits = 0,
- TokenType = "urn:ietf:params:oauth:token-type:jwt",
- };
- var channel = factory.CreateChannel();
- try
- {
- var token = channel.Issue(rst);
- return token as GenericXmlSecurityToken;
- }
- catch (ProtocolException ex)
- {
- Debug.Write(ex.Message);
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement