I think you need to call WindowsIdentity.Impersonate(phToken), where
phToken is the IntPtr returned by LogonUser.
RP
On Tuesday, October 7, 2014 3:51:00 PM UTC+1, Mauricio Liu wrote:
>
> I am using a method that successfully impersonates another windows user
> but when I connect to the database nhibernate reverts me to the windows
> user. Due to restrains in the organization I am forced to use the
> permissions of a windows user.
>
>
>
> My code:
>
> #region Properties
>
> private ISessionFactory factory = null;
>
> private ISession _session = null;
>
> #endregion
>
>
>
>
>
> public Repository()
>
> {
>
> Console.Write(WindowsIdentity.GetCurrent().Name); // successfully
> impersonated corp\userAdmin
>
> Configuration cfg = new Configuration();
>
> cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, conStr);
> //Integrated Security=SSPI
>
> cfg.Configure();
>
> factory = cfg.BuildSessionFactory(); // throws exception complaining
> corp\user1 cannot login
>
> _session = factory.OpenSession();
>
> }
>
>
>
> Impersonator code:
>
> http://snipplr.com/view/19323/impersonator/
>
>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.