开发者

Close LogonUser Handle if Failed Logon?

开发者 https://www.devze.com 2022-12-08 06:36 出处:网络
The LogonUser function http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx returns a handle that you can use to impersonate the user, when you are done using it youcall CloseHandle to close i

The LogonUser function http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx returns a handle that you can use to impersonate the user, when you are done using it you call CloseHandle to close it. My ques开发者_开发问答tion is, do you need to close the handle if the logon attempt fails (ie wrong username or password)?


No. LogonUser returns zero if it fails and no handle is created. Though, if you do call CloseHandle on it, CloseHandle should just return ERROR_INVALID_HANDLE.


The location pointed to by phToken is an "out" parameter, so if LogonUser() fails you should not count on it storing any reasonable value. You don't need to call CloseHandle() in such case.

0

精彩评论

暂无评论...
验证码 换一张
取 消