Tu peux utiliser cette procédure
Code : Tout sélectionner
; Code Web modifié ( n'exécutait pas d'argument de l'exe )
; 16/02/05
; PB 3.92
; Execute Runas avec paramètre + Password !!
; renvoie 0 si : commande inexistante / username ou Password incorrect
; Renvoie 1 si tout s'est bien passé
ProcedureDLL Runas(Username.s,Domain.s,Password.s,CommandLine.s,Argument.s)
FlagErreur=1
*lpUserName = AllocateMemory(1000)
*lpDomainName = AllocateMemory(1000)
*lpPassword = AllocateMemory(1000)
*lpApplication = AllocateMemory(1000)
*lpCommandLine = AllocateMemory(1000)
lpProcessInfo.PROCESS_INFORMATION
lpStartUpInfo.STARTUPINFO
;convert ansi strings to unicode
; UserName
MultiByteToWideChar_(#CP_ACP, 0, Username, -1, *lpUserName, 1000)
; DomainOrLocalMachine
MultiByteToWideChar_(#CP_ACP, 0, Domain, -1, *lpDomainName, 1000)
; Password
MultiByteToWideChar_(#CP_ACP, 0, Password, -1, *lpPassword, 1000)
; Application a lancer
MultiByteToWideChar_(#CP_ACP, 0, CommandLine, -1, *lpApplication, 1000)
; Arguments
If Argument<>"" And Left(Argument,1)<>" " : Argument=" "+Argument:EndIf ; ajout espace
MultiByteToWideChar_(#CP_ACP, 0, Argument, -1, *lpCommandLine, 1000)
If OpenLibrary(0, "ADVAPI32.DLL")
*F = IsFunction(0, "CreateProcessWithLogonW")
If *F
If CallFunctionFast(*F, *lpUserName, *lpDomainName, *lpPassword, 0, *lpApplication,*lpCommandLine,0,0,0,@lpStartUpInfo,@lpProcessInfo) = 0
FlagErreur=0
EndIf
Else
FlagErreur=0
EndIf
CloseLibrary(0)
EndIf
ProcedureReturn FlagErreur
EndProcedure
; test
;If Runas("utilisateur",".","pasword","c:\windows\system32\cmd.exe","/k dir c:\ /W")=0
; MessageRequester("Runas","Erreur")
;EndIf
et Utiliser ce code pour savoir si le couple utilisateur/compte est présent et valide
Code : Tout sélectionner
; Code Web modifié ( pour en faire une Librairie )
; 16/02/05
; PB 3.92
; Renvoie 1 (vrai) si utilisateur / password existe & correct
; renvoie 0 (erreur) si password vide ou compte / pwd incorrecte
ProcedureDLL UtilisateurExiste(NomUtilisateur.s,MotdePasse.s)
ret.l
username.s=NomUtilisateur
domain.s="."
password.s=MotdePasse
token.l
Result=LogonUser_(@username,@domain,@password,#LOGON32_LOGON_INTERACTIVE,#LOGON32_PROVIDER_DEFAULT,@token)
Result=ImpersonateLoggedOnUser_(token)
If Result
ret=1
Else
ret=0
EndIf
; ret=0
reverttoself_()
ProcedureReturn ret
EndProcedure
;test
;Debug UtilisateurExiste("Utilisateur","motdepasse")