Страница: 1 | 2 |
Вопрос: Windows - uZvers & pass
Добавлено: 08.11.08 20:59
Автор вопроса: Boconon | Web-сайт: microsoft.com | ICQ: 216390557
Помогите плиз! Копался в нете - ничего толкового не нашел...
как на VB:
1) получить список пользователей винды?
2) проверить, подходит ли пароль для учетной записи юзверя?
3) запустить прогу от имени юзверя? (если известно имя или пасс)
Буду благодарен за любые ссылки, куски кода, исходники (хотя эт я ужо слишком разогнался), мысли и т.д.
Ответить
Номер ответа: 13Автор ответа:
АдминистраторICQ: 278109632 Вопросов: 42Ответов: 3949
Web-сайт: domkratt.com Профиль | | #13
Добавлено: 11.11.08 01:25
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Declare Function LogonUser Lib "Advapi32" Alias "LogonUserA" (ByVal lpszUsername As String , ByVal lpszDomain As String , ByVal lpszPassword As String , ByVal dwLogonType As Long , ByVal dwLogonProvider As Long , phToken As Long ) As Long
Private Declare Function CreateProcessAsUserA Lib "kernel32" (ByVal hToken As Long , ByVal lpApplicationName As String , ByVal lpCommandLine As String , ByVal lpProcessAttributes As Long , ByVal lpThreadAttributes As Long , ByVal bInheritHandles As Long , ByVal dwCreationFlags As Long , ByVal lpEnvironment As String , ByVal lpCurrentDirectory As String , lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Const LOGON32_LOGON_INTERACTIVE = 2
Private Const LOGON32_PROVIDER_DEFAULT = 0
Private Const NORMAL_PRIORITY_CLASS = &H20
Private Const INVALID_HANDLE_VALUE = -1
Function CreateProcessAsUser(ByVal UserName As String , ByVal Domain As String , ByVal Password As String , ByVal CommandLine As String ) As Long
Dim hToken As Long
Dim SI As STARTUPINFO
Dim PI As PROCESS_INFORMATION
SI.cb = Len(SI)
CreateProcessAsUser = INVALID_HANDLE_VALUE
If Not LogonUser(UserName, Domain, Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken) Then Stop
Debug.Print Err.LastDllError
If Not CreateProcessAsUserA(hToken, vbNullString, CommandLine, ByVal 0&, ByVal 0&, False , NORMAL_PRIORITY_CLASS, ByVal 0&, ByVal 0&, SI, PI) Then Exit Function
CreateProcessAsUser = PI.hProcess
End Function
Private Sub Form_Load()
CreateProcessAsUser "TestUser" , "DOMKRATT_PC" , "MegaPassword1" , "notepad.exe"
End Sub
А вообще проще юзать АПИ CreateProcessWithLogon
Ответить
Номер ответа: 15Автор ответа:
АдминистраторICQ: 278109632 Вопросов: 42Ответов: 3949
Web-сайт: domkratt.com Профиль | | #15
Добавлено: 11.11.08 12:22
Private Const LOGON_WITH_PROFILE = &H1&
Private Const LOGON_NETCREDENTIALS_ONLY = &H2&
Private Const CREATE_DEFAULT_ERROR_MODE = &H4000000
Private Const CREATE_NEW_CONSOLE = &H10&
Private Const CREATE_NEW_PROCESS_GROUP = &H200&
Private Const CREATE_SEPARATE_WOW_VDM = &H800&
Private Const CREATE_SUSPENDED = &H4&
Private Const CREATE_UNICODE_ENVIRONMENT = &H400&
Private Const ABOVE_NORMAL_PRIORITY_CLASS = &H8000&
Private Const BELOW_NORMAL_PRIORITY_CLASS = &H4000&
Private Const HIGH_PRIORITY_CLASS = &H80&
Private Const IDLE_PRIORITY_CLASS = &H40&
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const REALTIME_PRIORITY_CLASS = &H100&
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Declare Function CreateProcessWithLogon Lib "Advapi32" Alias "CreateProcessWithLogonW" (ByVal lpUsername As Long , ByVal lpDomain As Long , ByVal lpPassword As Long , ByVal dwLogonFlags As Long , ByVal lpApplicationName As Long , ByVal lpCommandLine As Long , ByVal dwCreationFlags As Long , ByVal lpEnvironment As Long , ByVal lpCurrentDirectory As Long , lpStartupInfo As STARTUPINFO, lpProcessInfo As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long ) As Long
Private Sub Form_Load()
Dim lpUsername As String , lpDomain As String , lpPassword As String , lpApplicationName As String
Dim lpCommandLine As String , lpCurrentDirectory As String
Dim StartInfo As STARTUPINFO, ProcessInfo As PROCESS_INFORMATION
lpUsername = "OtherUser"
lpDomain = ""
lpPassword = "other_user_password"
lpApplicationName = "C:\WINNT\NOTEPAD.EXE"
lpCommandLine = vbNullString
lpCurrentDirectory = vbNullString
StartInfo.cb = LenB(StartInfo)
StartInfo.dwFlags = 0&
CreateProcessWithLogon StrPtr(lpUsername), StrPtr(lpDomain), StrPtr(lpPassword), LOGON_WITH_PROFILE, StrPtr(lpApplicationName), StrPtr(lpCommandLine), CREATE_DEFAULT_ERROR_MODE Or CREATE_NEW_CONSOLE Or CREATE_NEW_PROCESS_GROUP, ByVal 0&, StrPtr(lpCurrentDirectory), StartInfo, ProcessInfo
CloseHandle ProcessInfo.hThread
CloseHandle ProcessInfo.hProcess
Unload Me
End Sub
Ответить
Страница: 1 | 2 |
Поиск по форуму