From 184896004199c687acab009a71d82ca7d85fe2ce Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 27 Aug 2005 14:56:17 +0000 Subject: [PATCH] Implement LogonUserA. svn path=/trunk/; revision=17568 --- reactos/lib/advapi32/misc/logon.c | 72 ++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/reactos/lib/advapi32/misc/logon.c b/reactos/lib/advapi32/misc/logon.c index eb95f8c7102..68f6b30449d 100644 --- a/reactos/lib/advapi32/misc/logon.c +++ b/reactos/lib/advapi32/misc/logon.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: lib/advapi32/misc/logon.c @@ -131,17 +130,70 @@ CreateProcessAsUserW (HANDLE hToken, /* - * @unimplemented + * @implemented */ BOOL STDCALL -LogonUserA (LPSTR lpszUsername, - LPSTR lpszDomain, - LPSTR lpszPassword, - DWORD dwLogonType, - DWORD dwLogonProvider, - PHANDLE phToken) +LogonUserA(LPSTR lpszUsername, + LPSTR lpszDomain, + LPSTR lpszPassword, + DWORD dwLogonType, + DWORD dwLogonProvider, + PHANDLE phToken) { - return FALSE; + UNICODE_STRING UserName; + UNICODE_STRING Domain; + UNICODE_STRING Password; + NTSTATUS Status; + BOOL ret = FALSE; + + UserName.Buffer = NULL; + Domain.Buffer = NULL; + Password.Buffer = NULL; + + Status = RtlCreateUnicodeStringFromAsciiz(&UserName, + lpszUsername); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + goto UsernameDone; + } + + Status = RtlCreateUnicodeStringFromAsciiz(&Domain, + lpszDomain); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + goto DomainDone; + } + + Status = RtlCreateUnicodeStringFromAsciiz(&Password, + lpszPassword); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + goto PasswordDone; + } + + ret = LogonUserW(UserName.Buffer, + Domain.Buffer, + Password.Buffer, + dwLogonType, + dwLogonProvider, + phToken); + + if (Password.Buffer != NULL) + RtlFreeUnicodeString(&Password); + +PasswordDone: + if (Domain.Buffer != NULL) + RtlFreeUnicodeString(&Domain); + +DomainDone: + if (UserName.Buffer != NULL) + RtlFreeUnicodeString(&UserName); + +UsernameDone: + return ret; }