forked from Mirrors/wine-wine
netapi32: Implement NetUserDel.
parent
5934c2c9b1
commit
2207f20b5f
|
@ -91,26 +91,22 @@ static NET_API_STATUS NETAPI_ValidateServername(LPCWSTR ServerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* NETAPI_IsKnownUser
|
* NETAPI_FindUser
|
||||||
*
|
*
|
||||||
* Checks whether the user name indicates current user.
|
* Looks for a user in the user database.
|
||||||
|
* Returns a pointer to the entry in the user list when the user
|
||||||
|
* is found, NULL otherwise.
|
||||||
*/
|
*/
|
||||||
static BOOL NETAPI_IsKnownUser(LPCWSTR UserName)
|
static struct sam_user* NETAPI_FindUser(LPCWSTR UserName)
|
||||||
{
|
{
|
||||||
DWORD dwSize = UNLEN + 1;
|
struct sam_user *user;
|
||||||
BOOL Result;
|
|
||||||
LPWSTR buf;
|
|
||||||
|
|
||||||
if (!lstrcmpW(UserName, sAdminUserName) ||
|
LIST_FOR_EACH_ENTRY(user, &user_list, struct sam_user, entry)
|
||||||
!lstrcmpW(UserName, sGuestUserName))
|
{
|
||||||
return TRUE;
|
if(lstrcmpW(user->user_name, UserName) == 0)
|
||||||
NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) &buf);
|
return user;
|
||||||
Result = GetUserNameW(buf, &dwSize);
|
}
|
||||||
|
return NULL;
|
||||||
Result = Result && !lstrcmpW(UserName, buf);
|
|
||||||
NetApiBufferFree(buf);
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
|
@ -198,17 +194,24 @@ NET_API_STATUS WINAPI NetUserAdd(LPCWSTR servername,
|
||||||
NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
|
NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
|
||||||
{
|
{
|
||||||
NET_API_STATUS status;
|
NET_API_STATUS status;
|
||||||
FIXME("(%s, %s) stub!\n", debugstr_w(servername), debugstr_w(username));
|
struct sam_user *user;
|
||||||
|
|
||||||
status = NETAPI_ValidateServername(servername);
|
TRACE("(%s, %s)\n", debugstr_w(servername), debugstr_w(username));
|
||||||
if (status != NERR_Success)
|
|
||||||
|
if((status = NETAPI_ValidateServername(servername))!= NERR_Success)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (!NETAPI_IsKnownUser(username))
|
if ((user = NETAPI_FindUser(username)) == NULL)
|
||||||
return NERR_UserNotFound;
|
return NERR_UserNotFound;
|
||||||
|
|
||||||
/* Delete the user here */
|
list_remove(&user->entry);
|
||||||
return status;
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, user->home_dir);
|
||||||
|
HeapFree(GetProcessHeap(), 0, user->user_comment);
|
||||||
|
HeapFree(GetProcessHeap(), 0, user->user_logon_script_path);
|
||||||
|
HeapFree(GetProcessHeap(), 0, user);
|
||||||
|
|
||||||
|
return NERR_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
|
@ -232,7 +235,7 @@ NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level,
|
||||||
return NERR_InvalidComputer;
|
return NERR_InvalidComputer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!NETAPI_IsKnownUser(username))
|
if(!NETAPI_FindUser(username))
|
||||||
{
|
{
|
||||||
TRACE("User %s is unknown.\n", debugstr_w(username));
|
TRACE("User %s is unknown.\n", debugstr_w(username));
|
||||||
return NERR_UserNotFound;
|
return NERR_UserNotFound;
|
||||||
|
@ -404,7 +407,7 @@ NetUserGetLocalGroups(LPCWSTR servername, LPCWSTR username, DWORD level,
|
||||||
if (status != NERR_Success)
|
if (status != NERR_Success)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (!NETAPI_IsKnownUser(username))
|
if (!NETAPI_FindUser(username))
|
||||||
return NERR_UserNotFound;
|
return NERR_UserNotFound;
|
||||||
|
|
||||||
if (bufptr) *bufptr = NULL;
|
if (bufptr) *bufptr = NULL;
|
||||||
|
|
|
@ -259,7 +259,10 @@ static void run_userhandling_tests(void)
|
||||||
todo_wine ok(ret == NERR_Success, "Changing the password failed.\n");
|
todo_wine ok(ret == NERR_Success, "Changing the password failed.\n");
|
||||||
|
|
||||||
ret = pNetUserDel(NULL, sTestUserName);
|
ret = pNetUserDel(NULL, sTestUserName);
|
||||||
todo_wine ok(ret == NERR_Success, "Deleting the user failed.\n");
|
ok(ret == NERR_Success, "Deleting the user failed.\n");
|
||||||
|
|
||||||
|
ret = pNetUserDel(NULL, sTestUserName);
|
||||||
|
ok(ret == NERR_UserNotFound, "Deleting a nonexistent user returned 0x%08x\n",ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(access)
|
START_TEST(access)
|
||||||
|
|
Loading…
Reference in New Issue