ADFS Token generation working in C# but NOT in VB.Net

  • Thread starter Thread starter PavanAyitha
  • Start date Start date
P

PavanAyitha

Guest
Below is code in c# to get token from server. The code in C# is working fine and I am able to receive the token from server but when I write same syntax in VB.net then I get exception.

The framework for the code is same "4.6.2". App config of both the code are same

var sEndPointAddress = "url";
WS2007HttpBinding binding = new WS2007HttpBinding();
binding.Security.Message.EstablishSecurityContext = false;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
binding.Security.Mode = SecurityMode.TransportWithMessageCredential;
WSTrustChannelFactory trustChannelFactory = new WSTrustChannelFactory(binding, new EndpointAddress("https://IPAddress/adfs/services/trust/13/usernamemixed"));
trustChannelFactory.TrustVersion = TrustVersion.WSTrust13;
trustChannelFactory.Credentials.UserName.UserName = "username";
trustChannelFactory.Credentials.UserName.Password = "password";
RequestSecurityToken requestToken = new RequestSecurityToken(RequestTypes.Issue);
requestToken.AppliesTo = new EndpointReference(sEndPointAddress);
WSTrustChannel tokenClient = (WSTrustChannel)trustChannelFactory.CreateChannel();
var token = tokenClient.Issue(requestToken);



I have converted the same code in VB.Net but I am receving exception error.

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.

Below is code in VB.Net


Dim sEndPointAddress As String = "url"
Dim Binding As New WS2007HttpBinding()
Binding.Security.Message.EstablishSecurityContext = False
Binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None
Binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName
Binding.Security.Mode = SecurityMode.TransportWithMessageCredential
Dim trustChannelFactory As New WSTrustChannelFactory(Binding, New EndpointAddress("https://IPADDRESS/adfs/services/trust/13/usernamemixed"))
trustChannelFactory.TrustVersion = TrustVersion.WSTrust13
trustChannelFactory.Credentials.UserName.UserName = "UserName"
trustChannelFactory.Credentials.UserName.Password = "Password"
Dim requestToken As New RequestSecurityToken(RequestTypes.Issue)
requestToken.AppliesTo = New EndpointReference("URL")
Dim token As SecurityToken = trustChannelFactory.CreateChannel().Issue(requestToken)


Continue reading...
 
Back
Top