I have a NetTcpBinding
with SecurityMode.TransportWithMessageCredential
.
Transport.ClientCredentialType
is set to MessageCredentialType.Windows
, but I'm considering MessageCredentialType.UserName
.
Then there's a class DataStoreServerProxy for fetching database data which implements IDataStoreContract.
It contains methods such as this one:
Private Function Common_IDataStoreContract_ModifyData(ByVal ParamArray dmlStatements As ModificationStatement()) As ModificationResult Implements IDa开发者_如何学GotaStoreContract.ModifyData
Return wrappedDataStore.ModifyData(dmlStatements)
End Function
In order to get to that DB point, user must have already supplied the credentials. The question is, how to obtain them in those methods? Depending on the user name, I have to decide whether to allow access to some tables or not.
Username can be retrieved using OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name
精彩评论