mattjohnsonpint/SimpleImpersonation

Potentially unneccisary SafeHandle creation

kellyelton opened this issue · 1 comments

What is the purpose of putting the handle in a SafeHandle and returning it to the caller via an out parameter? If you look at the source for WindowsIdentity.Impersonate it looks like it already duplicates the handle into a safe handle.

https://github.com/mj1856/SimpleImpersonation/blob/041df51bf164f5ebd69f1196fb366a8cd9c45b5c/SimpleImpersonation/Impersonation.cs#L88

The version you reported this in held on to that handle and later disposed it to end the impersonation context. It was not returned to the end user, but held in a private instance field.

I have recently revised the API considerably with version 3.0.0, so this is no longer relevant. But thanks.