Thank you. I modified the the command to if (!(UsernameCStr = (char *)DSNewPClr(LStrLen(*Username)+1))) {cinErr = mFullErr; goto out; }
and the memory error is gone.
Yes, it's working. You are right, I can't close the handle. I tried a CallLibraryNode with kernel32.dll/CloseHandle but I get an error. So I included the line CloseHandle(*phToken);
after the function call LogonUserA(..) in the CIN and it's working without error. This means I need to include my ActiveDirectory between these commands. But this is my next step.
Jens