WSE3: authentication problem
- From: Sidharth <Sidharth@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 12 May 2006 08:20:01 -0700
Hello,
I have a winforms application that I'm trying to get to authenticate with a
web service. So in the winforms I get the currently logged in user and set
the web services credentials like this:
UsernameToken usernameToken = new UsernameToken(Environment.UserDomainName +
@"\" + Environment.UserName, "password", PasswordOption.SendPlainText);
ws.RequestSoapContext.Credentials.SetCredentials(new
CredentialSet(usernameToken));
ws.Ping();
On the web services side, I have a custom token manager, principal and
identity:
The CustomTokenManager overrides the AuthenticateToken:
protected override string AuthenticateToken(UsernameToken userName)
{
// call the db and check the login is OK
MyPrincipal principal = new MyPrincipal(userName.Username);
userName.Principal = principal;
return userName.Password;
}
Now the problem I'm getting is that in the Ping webmethod the user is null
if (MyUser == null)
{
throw new Exception("No authenticated user");
}
Where MyUser is:
protected MyPrincipal MyUser
{
get
{
if (_myPrincipal == null)
{
SoapContext context = RequestSoapContext.Current;
if (context != null)
{
foreach (SecurityToken t in
context.Credentials.UltimateReceiver.GetClientTokens())
{
if (t.Principal != null && t.Principal is MyPrincipal)
{
_myPrincipal = (MyPrincipal) t.Principal;
break;
}
}
}
}
return _myPrincipal;
}
}
I'm probably doing something really silly but I can't seem to figure out
what I'm doing wrong. Is it on the client side when I set the credentials? Or
is it the way I'm getting the credentials on the service side?
Using the WSE3 tool I've configured the web.config to use the custom token
manager.
<securityTokenManager>
<add type="WebService.MyTokenManager"
namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken" />
</securityTokenManager>
Any help would be much appreciated.
Thanks
Sidharth
.
- Follow-Ups:
- RE: WSE3: authentication problem
- From: Sidharth
- RE: WSE3: authentication problem
- Prev by Date: Re:WSE 3.0 To-Header and SoapActor
- Next by Date: wse 3.0 issue
- Previous by thread: Re:WSE 3.0 To-Header and SoapActor
- Next by thread: RE: WSE3: authentication problem
- Index(es):
Relevant Pages
|