как получить аутентифицированный идентификатор пользователя из wcf в nhibernate

Я реализовал настраиваемый контекст NHibernate (ICurrentSessionContext). В этом контексте я ввожу сеанс NHibernate, поэтому у меня есть настройка сеанса для каждого шаблона вызова. Хорошо, теперь я создал перехватчик, который принимает userId текущего зарегистрированного пользователя. Теперь я делаю следующее:

public ISession CurrentSession()
{
  // Get the WCF InstanceContext:
  var contextManager = OperationContext.Current.InstanceContext.Extensions.Find<NHibernateContextManager>();
  if (contextManager == null)
  {
    throw new InvalidOperationException(
      @"There is no context manager available.
      Check whether the NHibernateContextManager is added as InstanceContext extension.
      Make sure the service is being created with the NhServiceHostFactory.
      This Session Provider is intended only for WCF services.");
   }

   var session = contextManager.Session;
   AuditLogInterceptor interceptor = new AuditLogInterceptor();
   if (session == null)
   {
     session = this._factory.OpenSession(interceptor);
     interceptor.Session = session;

     contextManager.Session = session;
   }

   return contextManager.Session;
}

Мой AuditLogInterceptor принимает UserId, но я не знаю, как (откуда) чтобы получить этот userId.

6
задан Brian Tompsett - 汤莱恩 7 June 2015 в 11:11
поделиться