Problem using AddIPAddress when impersonating an admin user

I am trying to add a temporary IP address to the NIC using AddIPAddress when I log in as a non-admin user. The MSDN documentation for AddIPAddress states that ERROR_INVALID_HANDLE is returned as an error if the function is not called by the administrator.

Given that I have undergone an AddIPAddress call with API calls for LogonUser () and ImpersonateLoggedOnUser (). Now my application considers that it is registered as Admin, but AddIPAddress still does not work with ERROR_INVALID_HANDLE.

MSDN also states that ..

"Note: Group policies, corporate policies, and other network restrictions may prevent these features from completing successfully. Ensure that the application has the necessary network permissions before attempting to use these features.

Can I call AddIPAddress using impersonation? if so, how? I assume that I need to change the permissions mentioned above, but I do not understand what to do in this area.

Any help would be appreciated!

Additonal: I also drew a space while trying to call netsh (logged in again as a regular user) using CreateProcessAsUser using a handle provided by the admin user to start the process. Always returns errors indicating minor privileges.

+6
c ++ c winapi network-programming
source share
1 answer

If you are using Windows Vista, you may need to upgrade privileges.

In Vista, UAC is enabled by default. This makes it possible that even as an administrator, you use a limited user token, unless you explicitly raise it. When you do this, a dialog box will be provided to the user to allow or reject the request.

For more information, see Windows Vista Application Development Requirements for Compatibility with User Account Control .

You can try to use CheckTokenMembership to make sure you are properly raised after logging in as admin. I suspect that you are getting a limited user token and therefore are not fulfilling requests for privileged resources.

Good luck.

+1
source share

All Articles