I am writing an app for monitoring services on a remote machine. In order to achieve this [to my understanding] the app must first authenticate and retrieve a user token before being able to access service information.
Here is the code i am using to authenticate:
However as you may have guessed this is not working entirely...
It works fine when the login details are part of the local domain however however when login details of a remote machine are used [as above] login fails every time, also the ip address used [not the one in above example] is reachable.
Is this a limitation of the login method (imported from advapi32.dll) that it only works on local machines?
Here is the code i am using to authenticate:
VB.NET:
On Error Resume Next
tkn = IntPtr.Zero
dup_tkn = IntPtr.Zero
'logon and retrieve user-token
'imported from advapi32.dll
LogonUser("username", "81.11.211.11", "password", 2, 0, tkn)
'duplicate retrieved user-token
DuplicateToken(tkn, SecurityImpersonation, dup_tkn)
'change current identity to that of retrieved user-token
tmpID = New WindowsIdentity(dup_tkn)
tmpUser = tmpID.Impersonate
It works fine when the login details are part of the local domain however however when login details of a remote machine are used [as above] login fails every time, also the ip address used [not the one in above example] is reachable.
Is this a limitation of the login method (imported from advapi32.dll) that it only works on local machines?