Runtime Impersonation - Help !!!

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Runtime Impersonation - Help !!!

    Hi all

    I need to implement Runtime (Conditional) Impersonation in one of my ASP.NET
    Pages.

    If I use the <identity impersonate="true" /> in web.config file, it works
    fine.

    But in code, while I try to Impersonate I get Win32 error. I am using
    "Logon" Win32 API for get a specific token. But this API is returning error
    1314 : A required privilege is not held by the client

    I tried to resolve it by assinging the most probable Security priviledges to
    the "ASPNET" account by "Local Security Policy" snap-in. But nothing worked.

    Can anybody please help me ?

    Thanx in advance.




    Snig Guest

  2. Similar Questions and Discussions

    1. Impersonation
      Can someone explain this to me I have a web app I am trying to deploy for the Intranet of our company. I want to use integrated windows so have...
    2. ASP.Net Impersonation
      I am trying to understand Impersonation in the ASP.Net context. Here's what I DO understand: -Using Windows Authentication with...
    3. Impersonation in ASP.Net
      Hi, you can enter a domainuser for the anonymous access. Than you just have to activate impersonation for your web application. Modify the...
    4. Using Impersonation
      Is it ok to use impersonation in the web.config file for a web service? Let me tell you why I ask. My web service to ultimately connection to a...
    5. Runtime Impersonation
      Hi all I need to implement Runtime (Conditional) Impersonation in one of my ASP.NET Pages. If I use the <identity impersonate="true" /> in...
  3. #2

    Default Re: Runtime Impersonation - Help !!!

    By setting <identity impersonate="true" /> in web.config file the asp.net
    worker process assumes the identity of the person requesting the page.
    Most likely the user making the request does not have permissions to
    impersonate.

    Eric Mayne



    "Snig" <snigbb@yahoo.co.in> wrote in message
    news:#D1cHf2VDHA.1676@TK2MSFTNGP10.phx.gbl...
    > Hi all
    >
    > I need to implement Runtime (Conditional) Impersonation in one of my
    ASP.NET
    > Pages.
    >
    > If I use the <identity impersonate="true" /> in web.config file, it works
    > fine.
    >
    > But in code, while I try to Impersonate I get Win32 error. I am using
    > "Logon" Win32 API for get a specific token. But this API is returning
    error
    > 1314 : A required privilege is not held by the client
    >
    > I tried to resolve it by assinging the most probable Security priviledges
    to
    > the "ASPNET" account by "Local Security Policy" snap-in. But nothing
    worked.
    >
    > Can anybody please help me ?
    >
    > Thanx in advance.
    >
    >
    >
    >

    Eric Mayne Guest

  4. #3

    Default Runtime Impersonation - Help !!!

    I was having the same problem and this worked for me. I
    got this from the book ".NET Security" by Fischer and
    Smith, but there was a bug in their code. Hope this is
    helpful.

    public const int LOGON32_LOGON_INTERACTIVE = 2;
    public const int LOGON32_PROVIDER_DEFAULT = 0;
    public const int SECURITY_IMPERSONATION_LEVEL = 2;

    WindowsImpersonationContext impersonatedContext;
    WindowsIdentity tempIdentity;
    IntPtr token = IntPtr.Zero;
    IntPtr tokenDup = IntPtr.Zero;

    if ( LogonUser(userName, userDomain, userPassword,
    LOGON32_LOGON_INTERACTIVE,
    LOGON32_PROVIDER_DEFAULT, ref token) != 0 )
    {
    DuplicateToken(token, SECURITY_IMPERSONATION_LEVEL,
    ref tokenDup);
    tempIdentity = new WindowsIdentity(tokenDup);

    impersonatedContext = tempIdentity.Impersonate();
    }

    ....

    // and then when you're finished impersonating
    impersonatedContext.Undo();
    >-----Original Message-----
    >Hi all
    >
    >I need to implement Runtime (Conditional) Impersonation
    in one of my ASP.NET
    >Pages.
    >
    >If I use the <identity impersonate="true" /> in
    web.config file, it works
    >fine.
    >
    >But in code, while I try to Impersonate I get Win32
    error. I am using
    >"Logon" Win32 API for get a specific token. But this API
    is returning error
    >1314 : A required privilege is not held by the client
    >
    >I tried to resolve it by assinging the most probable
    Security priviledges to
    >the "ASPNET" account by "Local Security Policy" snap-in.
    But nothing worked.
    >
    >Can anybody please help me ?
    >
    >Thanx in advance.
    >
    >
    >
    >
    >.
    >
    Marni Alvarez Guest

  5. #4

    Default Re: Runtime Impersonation - Help !!!

    Thanx Marni.

    But I've written exactly the same code that you have mentioned here.
    Still the "LOGONUSER" API sends error : 1314 : A required privilege is not
    held by the client

    I saw somewhere in the Web that this process requires ASPNET user to have
    permission "Act As a Part of the OS". I granted that permission too. Still
    it doesn't work !

    Any clue ?


    "Marni Alvarez" <malvarez@nextrx.com> wrote in message
    news:01d001c3579c$c1bb0600$a601280a@phx.gbl...
    > I was having the same problem and this worked for me. I
    > got this from the book ".NET Security" by Fischer and
    > Smith, but there was a bug in their code. Hope this is
    > helpful.
    >
    > public const int LOGON32_LOGON_INTERACTIVE = 2;
    > public const int LOGON32_PROVIDER_DEFAULT = 0;
    > public const int SECURITY_IMPERSONATION_LEVEL = 2;
    >
    > WindowsImpersonationContext impersonatedContext;
    > WindowsIdentity tempIdentity;
    > IntPtr token = IntPtr.Zero;
    > IntPtr tokenDup = IntPtr.Zero;
    >
    > if ( LogonUser(userName, userDomain, userPassword,
    > LOGON32_LOGON_INTERACTIVE,
    > LOGON32_PROVIDER_DEFAULT, ref token) != 0 )
    > {
    > DuplicateToken(token, SECURITY_IMPERSONATION_LEVEL,
    > ref tokenDup);
    > tempIdentity = new WindowsIdentity(tokenDup);
    >
    > impersonatedContext = tempIdentity.Impersonate();
    > }
    >
    > ...
    >
    > // and then when you're finished impersonating
    > impersonatedContext.Undo();
    >
    > >-----Original Message-----
    > >Hi all
    > >
    > >I need to implement Runtime (Conditional) Impersonation
    > in one of my ASP.NET
    > >Pages.
    > >
    > >If I use the <identity impersonate="true" /> in
    > web.config file, it works
    > >fine.
    > >
    > >But in code, while I try to Impersonate I get Win32
    > error. I am using
    > >"Logon" Win32 API for get a specific token. But this API
    > is returning error
    > >1314 : A required privilege is not held by the client
    > >
    > >I tried to resolve it by assinging the most probable
    > Security priviledges to
    > >the "ASPNET" account by "Local Security Policy" snap-in.
    > But nothing worked.
    > >
    > >Can anybody please help me ?
    > >
    > >Thanx in advance.
    > >
    > >
    > >
    > >
    > >.
    > >

    Snig Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139