A colleague and myself revisited this problem. We found that the problem was due to the Character Set used in the Visual Studio Project Settings. Visual Studio by default, sets character set to Use Unicode Character Set
. However our application needs to use ASCII character set as our application needs to read input from command line. So the input read from command line was ASCII but we were passing that input to Wide character version of LookupAccountName
API i.e. LookupAccountNameW
. This caused API to return 1332 error code.
So we changed the Character Set to "Not Set" and recompiled the application. This ensured that correct form of the API, LookupAccountNamA
, is used. This resolved the problem. I believe setting Character Set to "" will also solve the problem.
Hope this will be useful.