|
| Iniciado por guest, 07,abr. 2015 03:58 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 07,abril 2015 - 03:58 |
Hi,
How can we do impersonate easily in WD 20? My application need to use NTLM authentication to acces to a database in another machine inside the same network.
As far as my research, I need to use .NET system.security.principal assembly to use NetworkIdentity class. The thing is, i cant get it work yet.Here my code :
RetourFonction est un booléen // Type C :BOOL LpszUsername est une chaîne // Type C :LPSTR, c'est l'adresse d'une chaîne, il est aussi possible de spécifier directement une chaîne LpszDomain est une chaîne // Type C :LPSTR, c'est l'adresse d'une chaîne, il est aussi possible de spécifier directement une chaîne LpszPassword est une chaîne// Type C :LPSTR, c'est l'adresse d'une chaîne, il est aussi possible de spécifier directement une chaîne dwLogonType est un entier = 2 // Type C :DWORD mode logon interactif dwLogonProvider est un entier = 0 // Type C :DWORD mode LOGON32_PROVIDER_DEFAULT par defaut NTLM clPhToken est un IntPtr = Null// Type C :PHANDLE nPhtoken est un entier szLpbuffer est une chaîne ASCIIZ de 32 nSize est un entier=31 pclImpersonationContext est un WindowsImpersonationContext dynamique pclWid est un WindowsIdentity dynamique pclWidAdmin est un WindowsImpersonationContext dynamique
RetourFonction= API("ADVAPI32","LogonUserA",& LpszUsername,& LpszDomain,& LpszPassword,dwLogonType,dwLogonProvider, & clPhToken)
pclWid = WindowsIdentity.GetCurrent() Info (pclWid.get_Name() + "/n "+pclWid.get_Token()+" "+pclWid.Token+" "+pclWid.get_AuthenticationType()) // Begin impersonating the user nPhtoken = & clPhToken Info (nPhtoken)
gpclMyIdentity est un WindowsIdentity dynamique = allouer un WindowsIdentity (clPhToken) //myIdentity.Impersonate (clPhToken) //WindowsIdentity.Impersonate(clPhToken)
Any idea? Cheers |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,abril 2015 - 02:59 |
Perhaps you have a session context already established with the server with a different set of credentials than that being passed, a mapped drive or something. Multiple sessions to a server only allowed if all use same credentials.
Dave B. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,abril 2015 - 06:23 |
Actually it is the case. The error occurs because i'm trying to re-authenticate the currently logged in account. I'm an idiot. If I authenticate with another account, it works!
Thanks Dave for your answer. Appreciate it. |
| |
| |
| | | |
|
| | | | |
| | |
|