Impersonate via a remote workgroup

  • Thread starter Dominick Baier [DevelopMentor]
  • Start date
D

Dominick Baier [DevelopMentor]

sorry. this only works if you are trying to access remote resources that
"know" the account you are impersonating.
 
D

Dino

i am trying to impersanate a remote user on a workgroup(NOT Domain) account.
This does not seem to work. Only works for domain or local user. Anyone have
any ideas.

Thanks

Dim tempWindowsIdentity As WindowsIdentity
Dim token As IntPtr = IntPtr.Zero
Dim tokenDuplicate As IntPtr = IntPtr.Zero
impersonateValidUser = False
If RevertToSelf() Then
If LogonUserA(userName, domain, password,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
If DuplicateToken(token, 2, tokenDuplicate) <> 0 Then
tempWindowsIdentity = New WindowsIdentity(tokenDuplicate)
impersonationContext = tempWindowsIdentity.Impersonate()
If Not impersonationContext Is Nothing Then
impersonateValidUser = True
End If
End If
End If
End If
If Not tokenDuplicate.Equals(IntPtr.Zero) Then
CloseHandle(tokenDuplicate)
End If
If Not token.Equals(IntPtr.Zero) Then
CloseHandle(token)
End If
 
M

melle

Hi Dominick,

I've found multiple entries from that state that we should use
NEW_CREDENTIAL in order to log on cross domain... I tried it, and
LogonUser does not fail... that is true, but when I do
ImpersonateLoggedOnUser it doesn't seem to impersonate at all.

Can you tell us what the next step should be?

I am trying to impersonate a user from another domain, that is a domain
my computer is not a part of. All the credentials are ok. that is not a
problem. It just doesn't accept them. (error 1326)

Please advise,

Melle
 
M

melle

Hi Dominick,

I've found multiple posts on google from you, that state that we should
use
NEW_CREDENTIAL in order to log on cross domain... I tried it, and
LogonUser does not fail... that is true, but when I do
ImpersonateLoggedOnUser it doesn't seem to impersonate at all.


Can you tell us what the next step should be?


I am trying to impersonate a user from another domain, that is a domain

my computer is not a part of. All the credentials are ok. that is not a

problem. It just doesn't accept them. (error 1326)


Please advise,


Melle
 
D

Dominick Baier

Hi,

use the token from LogonUser to

call WindowsIdentity.Impersonate(token);
then do the resource access


dominick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top