Hi Group!
I'm writing a custom authentication filter (derived from CHttpFilter).
In the constructor, I call the loadConfig() function, which tries to
read a configuration file from a shared location on the local network.
When I try to open the file, I get a permission denied error. A call
to GetUserName() returns "SYSTEM". So I tried calling LogonUser() and
ImpersonateLoggedOnUser() with a valid domain user that has full access
to the file, before trying to open it. A call to GetUserName() returns
the name of the network user. I still get permission denied errors.
Appropriate Parts of the code:
rc = LogonUser(userid, domain, password, LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT, &token);
// check for errors
rc = ImpersonateLoggedOnUser(token);
// check for errors
h = CreateFile(configFile, GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
// check for errors
// process the file
CloseHandle(h);
RevertToSelf();
Why isn't it working?
Thanks!
jcf
>> Stay informed about: File Permission Problems In Authentication Filter