Új hozzászólás Aktív témák

  • kampi_

    csendes tag

    Sziasztok!

    Adott ez a kód:

    STARTUPINFO StartInfo;
    PROCESS_INFORMATION ProcInfo;
    TOKEN_PRIVILEGES tp;
    memset(&ProcInfo, 0, sizeof(ProcInfo));
    memset(&StartInfo, 0 , sizeof(StartInfo));
    StartInfo.cb = sizeof(StartInfo);
    HANDLE handle = NULL;

    if (!OpenProcessToken(GetCurrentProcess(),
    TOKEN_ALL_ACCESS, &handle)) printf("\nOpenProcessError");

    if (!LookupPrivilegeValue(NULL,SE_TCB_NAME,
    //SE_TCB_NAME,
    &tp.Privileges[0].Luid)) {
    printf("\nLookupPriv error");
    }

    tp.PrivilegeCount = 1;
    tp.Privileges[0].Attributes =
    SE_PRIVILEGE_ENABLED;//SE_PRIVILEGE_ENABLED;
    if (!AdjustTokenPrivileges(handle, FALSE, &tp, 0, NULL, 0)) {
    printf("\nAdjustToken error");
    }

    i = LogonUser(user, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &handle);
    printf("\nLogonUser return : %d",i);
    i = GetLastError();
    printf("\nLogonUser getlast : %d",i);
    if (! ImpersonateLoggedOnUser(handle) ) printf("\nImpLoggedOnUser!");

    i = CreateProcessAsUser(handle, "c:\\windows\\system32\\notepad.exe",NULL, NULL, NULL, true,
    CREATE_UNICODE_ENVIRONMENT |NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL,
    &StartInfo, &ProcInfo);
    printf("\nCreateProcessAsUser return : %d",i);
    i = GetLastError();
    printf("\nCreateProcessAsUser getlast : %d",i);

    CloseHandle(handle);
    CloseHandle(ProcInfo.hProcess);
    CloseHandle(ProcInfo.hThread);

    A domaint, user, és passwordot egy fájlból olvasom be. A probléma az, hogy a CreateProcessAsuser mindig 1314-es hibával száll el, ami "A required privilige is not held by the client". A kérdés mit csinálok rosszul, vagy hogyan tudnék jogot adni a handle-nek? Gondolom annak kellene.

    Előre is köszi a segítséget!

    kampi

Új hozzászólás Aktív témák