Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. logonuser returns 1314

logonuser returns 1314

Scheduled Pinned Locked Moved C / C++ / MFC
databasesecurityhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vineeshV
    wrote on last edited by
    #1

    when i try to impersonate the process to a different user,the logonUser call fails with error no 1314 (privilage not held by the client ) in windows 2000 series it was working in xp series of os Please find sample code below #define SECURITY_WIN32 #include <windows.h> #include <tchar.h> #include <stdio.h> #include <conio.h> #include <sspi.h> #include <lm.h> #include <lmcons.h> #include <userenv.h> #ifndef SEC_I_COMPLETE_NEEDED #include <issperr.h> #endif typedef struct _AUTH_SEQ { BOOL fInitialized; BOOL fHaveCredHandle; BOOL fHaveCtxtHandle; CredHandle hcred; struct _SecHandle hctxt; } AUTH_SEQ, *PAUTH_SEQ; // Function pointers ACCEPT_SECURITY_CONTEXT_FN _AcceptSecurityContext = NULL; ACQUIRE_CREDENTIALS_HANDLE_FN _AcquireCredentialsHandle = NULL; COMPLETE_AUTH_TOKEN_FN _CompleteAuthToken = NULL; DELETE_SECURITY_CONTEXT_FN _DeleteSecurityContext = NULL; FREE_CONTEXT_BUFFER_FN _FreeContextBuffer = NULL; FREE_CREDENTIALS_HANDLE_FN _FreeCredentialsHandle = NULL; INITIALIZE_SECURITY_CONTEXT_FN _InitializeSecurityContext = NULL; QUERY_SECURITY_PACKAGE_INFO_FN _QuerySecurityPackageInfo = NULL; QUERY_SECURITY_CONTEXT_TOKEN_FN _QuerySecurityContextToken = NULL; #define CheckAndLocalFree(ptr) \ if (ptr != NULL) \ { \ LocalFree(ptr); \ ptr = NULL; \ } #pragma comment(lib, "netapi32.lib") LPVOID RetrieveTokenInformationClass( HANDLE hToken, TOKEN_INFORMATION_CLASS InfoClass, LPDWORD lpdwSize) { LPVOID pInfo = NULL; BOOL fSuccess = FALSE; __try { *lpdwSize = 0; GetTokenInformation( hToken, InfoClass, NULL, *lpdwSize, lpdwSize); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { _tprintf(_T("GetTokenInformation failed with %d\n"), GetLastError()); __leave; } pInfo = LocalAlloc(LPTR, *lpdwSize); if (pInfo == NULL) { _tprintf(_T("LocalAlloc failed with %d\n"), GetLastError()); __leave; } if (!GetTokenInformation( hToken, InfoClass, pInfo, *lpdwSize, lpdwSize)) { _tprintf(_T("GetTokenInformation failed with %d\n"), GetLastError()); __leave; } fSuccess

    D 1 Reply Last reply
    0
    • V vineeshV

      when i try to impersonate the process to a different user,the logonUser call fails with error no 1314 (privilage not held by the client ) in windows 2000 series it was working in xp series of os Please find sample code below #define SECURITY_WIN32 #include <windows.h> #include <tchar.h> #include <stdio.h> #include <conio.h> #include <sspi.h> #include <lm.h> #include <lmcons.h> #include <userenv.h> #ifndef SEC_I_COMPLETE_NEEDED #include <issperr.h> #endif typedef struct _AUTH_SEQ { BOOL fInitialized; BOOL fHaveCredHandle; BOOL fHaveCtxtHandle; CredHandle hcred; struct _SecHandle hctxt; } AUTH_SEQ, *PAUTH_SEQ; // Function pointers ACCEPT_SECURITY_CONTEXT_FN _AcceptSecurityContext = NULL; ACQUIRE_CREDENTIALS_HANDLE_FN _AcquireCredentialsHandle = NULL; COMPLETE_AUTH_TOKEN_FN _CompleteAuthToken = NULL; DELETE_SECURITY_CONTEXT_FN _DeleteSecurityContext = NULL; FREE_CONTEXT_BUFFER_FN _FreeContextBuffer = NULL; FREE_CREDENTIALS_HANDLE_FN _FreeCredentialsHandle = NULL; INITIALIZE_SECURITY_CONTEXT_FN _InitializeSecurityContext = NULL; QUERY_SECURITY_PACKAGE_INFO_FN _QuerySecurityPackageInfo = NULL; QUERY_SECURITY_CONTEXT_TOKEN_FN _QuerySecurityContextToken = NULL; #define CheckAndLocalFree(ptr) \ if (ptr != NULL) \ { \ LocalFree(ptr); \ ptr = NULL; \ } #pragma comment(lib, "netapi32.lib") LPVOID RetrieveTokenInformationClass( HANDLE hToken, TOKEN_INFORMATION_CLASS InfoClass, LPDWORD lpdwSize) { LPVOID pInfo = NULL; BOOL fSuccess = FALSE; __try { *lpdwSize = 0; GetTokenInformation( hToken, InfoClass, NULL, *lpdwSize, lpdwSize); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { _tprintf(_T("GetTokenInformation failed with %d\n"), GetLastError()); __leave; } pInfo = LocalAlloc(LPTR, *lpdwSize); if (pInfo == NULL) { _tprintf(_T("LocalAlloc failed with %d\n"), GetLastError()); __leave; } if (!GetTokenInformation( hToken, InfoClass, pInfo, *lpdwSize, lpdwSize)) { _tprintf(_T("GetTokenInformation failed with %d\n"), GetLastError()); __leave; } fSuccess

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      vineeshV wrote:

      Please help me ....

      Why not help us by removing 99% of your code from this post? Do you honestly think anyone would spend their valuable time reading through all of this? :rolleyes:

      "Love people and use things, not love things and use people." - Unknown

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups