G
Guest
I am currently using .NET 2.0's secure TCP channel for remoting, and have run
into a problem where if a user doesn't log out for a while (usually seems to
be about two days), delegation fails. Having the user log off and back on
fixes the problem (as does locking and unlocking the workstation).
The user is still identified (their username is being retrieved through
Thread.CurrentPrincipal), but when I impersonate the user and try to execute
a database query (using Windows Authentication) I receive a SqlException:
"Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection."
The client config file contains:
<channel ref='tcp' secure='true' impersonate="true"
tokenImpersonationLevel="Delegation" protectionLevel='EncryptAndSign'
servicePrincipalName="serviceuser@domain">
<clientProviders>
<formatter ref='binary' />
</clientProviders>
</channel>
and the server config file contains:
<channel ref="tcp" port="8081" secure="true"
tokenImpersonationLevel="Delegation" protectionLevel="EncryptAndSign">
<serverProviders>
<formatter ref="binary" />
</serverProviders>
</channel>
When impersonating, I am using this code:
If TypeOf Thread.CurrentPrincipal.Identity Is WindowsIdentity Then
context = DirectCast(Thread.CurrentPrincipal.Identity,
WindowsIdentity).Impersonate()
End If
Because this code does not throw an exception, I think the CurrentPrincipal
is a GenericPrincipal instead of a WindowsPricipal.
Why is the user principal not being authenticated as a WindowsPrincipal if
the user stays logged in for a long period of time?
into a problem where if a user doesn't log out for a while (usually seems to
be about two days), delegation fails. Having the user log off and back on
fixes the problem (as does locking and unlocking the workstation).
The user is still identified (their username is being retrieved through
Thread.CurrentPrincipal), but when I impersonate the user and try to execute
a database query (using Windows Authentication) I receive a SqlException:
"Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection."
The client config file contains:
<channel ref='tcp' secure='true' impersonate="true"
tokenImpersonationLevel="Delegation" protectionLevel='EncryptAndSign'
servicePrincipalName="serviceuser@domain">
<clientProviders>
<formatter ref='binary' />
</clientProviders>
</channel>
and the server config file contains:
<channel ref="tcp" port="8081" secure="true"
tokenImpersonationLevel="Delegation" protectionLevel="EncryptAndSign">
<serverProviders>
<formatter ref="binary" />
</serverProviders>
</channel>
When impersonating, I am using this code:
If TypeOf Thread.CurrentPrincipal.Identity Is WindowsIdentity Then
context = DirectCast(Thread.CurrentPrincipal.Identity,
WindowsIdentity).Impersonate()
End If
Because this code does not throw an exception, I think the CurrentPrincipal
is a GenericPrincipal instead of a WindowsPricipal.
Why is the user principal not being authenticated as a WindowsPrincipal if
the user stays logged in for a long period of time?