2 * Copyright 2002 Andriy Palamarchuk
4 * netapi32 access functions
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WIN32_NO_STATUS
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
36 #include "wine/list.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
40 /* NOTE: So far, this is implemented to support tests that require user logins,
41 * but not designed to handle real user databases. Those should probably
42 * be synced with either the host's user database or with Samba.
44 * FIXME: The user database should hold all the information the USER_INFO_4 struct
45 * needs, but for the first try, I will just implement the USER_INFO_1 fields.
51 WCHAR user_name[LM20_UNLEN+1];
52 WCHAR user_password[PWLEN + 1];
53 DWORD sec_since_passwd_change;
58 LPWSTR user_logon_script_path;
61 static struct list user_list = LIST_INIT( user_list );
63 BOOL NETAPI_IsLocalComputer(LPCWSTR ServerName);
65 /************************************************************
66 * NETAPI_ValidateServername
68 * Validates server name
70 static NET_API_STATUS NETAPI_ValidateServername(LPCWSTR ServerName)
74 if (ServerName[0] == 0)
75 return ERROR_BAD_NETPATH;
77 ((ServerName[0] == '\\') &&
78 (ServerName[1] != '\\'))
80 ((ServerName[0] == '\\') &&
81 (ServerName[1] == '\\') &&
84 return ERROR_INVALID_NAME;
89 /************************************************************
92 * Looks for a user in the user database.
93 * Returns a pointer to the entry in the user list when the user
94 * is found, NULL otherwise.
96 static struct sam_user* NETAPI_FindUser(LPCWSTR UserName)
98 struct sam_user *user;
100 LIST_FOR_EACH_ENTRY(user, &user_list, struct sam_user, entry)
102 if(lstrcmpW(user->user_name, UserName) == 0)
108 static BOOL NETAPI_IsCurrentUser(LPCWSTR username)
110 LPWSTR curr_user = NULL;
114 dwSize = LM20_UNLEN+1;
115 curr_user = HeapAlloc(GetProcessHeap(), 0, dwSize);
118 ERR("Failed to allocate memory for user name.\n");
121 if(!GetUserNameW(curr_user, &dwSize))
123 ERR("Failed to get current user's user name.\n");
126 if (!lstrcmpW(curr_user, username))
132 HeapFree(GetProcessHeap(), 0, curr_user);
136 /************************************************************
137 * NetUserAdd (NETAPI32.@)
139 NET_API_STATUS WINAPI NetUserAdd(LPCWSTR servername,
140 DWORD level, LPBYTE bufptr, LPDWORD parm_err)
142 NET_API_STATUS status;
143 struct sam_user * su = NULL;
145 FIXME("(%s, %d, %p, %p) stub!\n", debugstr_w(servername), level, bufptr, parm_err);
147 if((status = NETAPI_ValidateServername(servername)) != NERR_Success)
152 /* Level 3 and 4 are identical for the purposes of NetUserAdd */
155 FIXME("Level 3 and 4 not implemented.\n");
158 FIXME("Level 2 not implemented.\n");
162 PUSER_INFO_1 ui = (PUSER_INFO_1) bufptr;
163 su = HeapAlloc(GetProcessHeap(), 0, sizeof(struct sam_user));
166 status = NERR_InternalError;
170 if(lstrlenW(ui->usri1_name) > LM20_UNLEN)
172 status = NERR_BadUsername;
176 /*FIXME: do other checks for a valid username */
177 lstrcpyW(su->user_name, ui->usri1_name);
179 if(lstrlenW(ui->usri1_password) > PWLEN)
181 /* Always return PasswordTooShort on invalid passwords. */
182 status = NERR_PasswordTooShort;
185 lstrcpyW(su->user_password, ui->usri1_password);
187 su->sec_since_passwd_change = ui->usri1_password_age;
188 su->user_priv = ui->usri1_priv;
189 su->user_flags = ui->usri1_flags;
191 /*FIXME: set the other LPWSTRs to NULL for now */
193 su->user_comment = NULL;
194 su->user_logon_script_path = NULL;
196 list_add_head(&user_list, &su->entry);
200 TRACE("Invalid level %d specified.\n", level);
201 status = ERROR_INVALID_LEVEL;
205 HeapFree(GetProcessHeap(), 0, su);
210 /************************************************************
211 * NetUserDel (NETAPI32.@)
213 NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
215 NET_API_STATUS status;
216 struct sam_user *user;
218 TRACE("(%s, %s)\n", debugstr_w(servername), debugstr_w(username));
220 if((status = NETAPI_ValidateServername(servername))!= NERR_Success)
223 if ((user = NETAPI_FindUser(username)) == NULL)
224 return NERR_UserNotFound;
226 list_remove(&user->entry);
228 HeapFree(GetProcessHeap(), 0, user->home_dir);
229 HeapFree(GetProcessHeap(), 0, user->user_comment);
230 HeapFree(GetProcessHeap(), 0, user->user_logon_script_path);
231 HeapFree(GetProcessHeap(), 0, user);
236 /************************************************************
237 * NetUserGetInfo (NETAPI32.@)
239 NET_API_STATUS WINAPI
240 NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level,
243 NET_API_STATUS status;
244 TRACE("(%s, %s, %d, %p)\n", debugstr_w(servername), debugstr_w(username),
246 status = NETAPI_ValidateServername(servername);
247 if (status != NERR_Success)
250 if(!NETAPI_IsLocalComputer(servername))
252 FIXME("Only implemented for local computer, but remote server"
253 "%s was requested.\n", debugstr_w(servername));
254 return NERR_InvalidComputer;
257 if(!NETAPI_FindUser(username) && !NETAPI_IsCurrentUser(username))
259 TRACE("User %s is unknown.\n", debugstr_w(username));
260 return NERR_UserNotFound;
270 name_sz = lstrlenW(username) + 1;
273 NetApiBufferAllocate(sizeof(USER_INFO_0) + name_sz * sizeof(WCHAR),
276 ui = (PUSER_INFO_0) *bufptr;
277 ui->usri0_name = (LPWSTR) (*bufptr + sizeof(USER_INFO_0));
280 lstrcpyW(ui->usri0_name, username);
288 NET_API_STATUS status;
289 /* sizes of the field buffers in WCHARS */
290 int name_sz, comment_sz, usr_comment_sz, full_name_sz;
297 status = NetUserGetInfo(servername, username, 0, (LPBYTE *) &ui0);
298 if (status != NERR_Success)
300 NetApiBufferFree(ui0);
303 name_sz = lstrlenW(ui0->usri0_name) + 1;
306 NetApiBufferAllocate(sizeof(USER_INFO_10) +
307 (name_sz + comment_sz + usr_comment_sz +
308 full_name_sz) * sizeof(WCHAR),
310 ui = (PUSER_INFO_10) *bufptr;
311 ui->usri10_name = (LPWSTR) (*bufptr + sizeof(USER_INFO_10));
312 ui->usri10_comment = (LPWSTR) (
313 ((PBYTE) ui->usri10_name) + name_sz * sizeof(WCHAR));
314 ui->usri10_usr_comment = (LPWSTR) (
315 ((PBYTE) ui->usri10_comment) + comment_sz * sizeof(WCHAR));
316 ui->usri10_full_name = (LPWSTR) (
317 ((PBYTE) ui->usri10_usr_comment) + usr_comment_sz * sizeof(WCHAR));
320 lstrcpyW(ui->usri10_name, ui0->usri0_name);
321 NetApiBufferFree(ui0);
322 ui->usri10_comment[0] = 0;
323 ui->usri10_usr_comment[0] = 0;
324 ui->usri10_full_name[0] = 0;
330 static const WCHAR homedirW[] = {'H','O','M','E',0};
333 NET_API_STATUS status;
334 /* sizes of the field buffers in WCHARS */
335 int name_sz, password_sz, home_dir_sz, comment_sz, script_path_sz;
337 password_sz = 1; /* not filled out for security reasons for NetUserGetInfo*/
342 status = NetUserGetInfo(servername, username, 0, (LPBYTE *) &ui0);
343 if (status != NERR_Success)
345 NetApiBufferFree(ui0);
348 name_sz = lstrlenW(ui0->usri0_name) + 1;
349 home_dir_sz = GetEnvironmentVariableW(homedirW, NULL,0);
351 NetApiBufferAllocate(sizeof(USER_INFO_1) +
352 (name_sz + password_sz + home_dir_sz +
353 comment_sz + script_path_sz) * sizeof(WCHAR),
356 ui = (PUSER_INFO_1) *bufptr;
357 ui->usri1_name = (LPWSTR) (ui + 1);
358 ui->usri1_password = ui->usri1_name + name_sz;
359 ui->usri1_home_dir = ui->usri1_password + password_sz;
360 ui->usri1_comment = ui->usri1_home_dir + home_dir_sz;
361 ui->usri1_script_path = ui->usri1_comment + comment_sz;
363 lstrcpyW(ui->usri1_name, ui0->usri0_name);
364 NetApiBufferFree(ui0);
365 ui->usri1_password[0] = 0;
366 ui->usri1_password_age = 0;
368 GetEnvironmentVariableW(homedirW, ui->usri1_home_dir,home_dir_sz);
369 ui->usri1_comment[0] = 0;
371 ui->usri1_script_path[0] = 0;
401 FIXME("Level %d is not implemented\n", level);
402 return NERR_InternalError;
405 TRACE("Invalid level %d is specified\n", level);
406 return ERROR_INVALID_LEVEL;
411 /************************************************************
412 * NetUserGetLocalGroups (NETAPI32.@)
414 NET_API_STATUS WINAPI
415 NetUserGetLocalGroups(LPCWSTR servername, LPCWSTR username, DWORD level,
416 DWORD flags, LPBYTE* bufptr, DWORD prefmaxlen,
417 LPDWORD entriesread, LPDWORD totalentries)
419 NET_API_STATUS status;
421 FIXME("(%s, %s, %d, %08x, %p %d, %p, %p) stub!\n",
422 debugstr_w(servername), debugstr_w(username), level, flags, bufptr,
423 prefmaxlen, entriesread, totalentries);
425 status = NETAPI_ValidateServername(servername);
426 if (status != NERR_Success)
429 if (!NETAPI_FindUser(username))
430 return NERR_UserNotFound;
432 if (bufptr) *bufptr = NULL;
433 if (entriesread) *entriesread = 0;
434 if (totalentries) *totalentries = 0;
439 /************************************************************
440 * NetUserEnum (NETAPI32.@)
442 NET_API_STATUS WINAPI
443 NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr,
444 DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries,
445 LPDWORD resume_handle)
447 FIXME("(%s,%d, 0x%d,%p,%d,%p,%p,%p) stub!\n", debugstr_w(servername), level,
448 filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
450 return ERROR_ACCESS_DENIED;
453 /************************************************************
454 * ACCESS_QueryAdminDisplayInformation
456 * Creates a buffer with information for the Admin User
458 static void ACCESS_QueryAdminDisplayInformation(PNET_DISPLAY_USER *buf, PDWORD pdwSize)
460 static const WCHAR sAdminUserName[] = {
461 'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
463 /* sizes of the field buffers in WCHARS */
464 int name_sz, comment_sz, full_name_sz;
465 PNET_DISPLAY_USER usr;
468 name_sz = lstrlenW(sAdminUserName);
472 *pdwSize = sizeof(NET_DISPLAY_USER);
473 *pdwSize += (name_sz + comment_sz + full_name_sz) * sizeof(WCHAR);
474 NetApiBufferAllocate(*pdwSize, (LPVOID *) buf);
477 usr->usri1_name = (LPWSTR) ((PBYTE) usr + sizeof(NET_DISPLAY_USER));
478 usr->usri1_comment = (LPWSTR) (
479 ((PBYTE) usr->usri1_name) + name_sz * sizeof(WCHAR));
480 usr->usri1_full_name = (LPWSTR) (
481 ((PBYTE) usr->usri1_comment) + comment_sz * sizeof(WCHAR));
484 lstrcpyW(usr->usri1_name, sAdminUserName);
485 usr->usri1_comment[0] = 0;
486 usr->usri1_flags = UF_SCRIPT | UF_NORMAL_ACCOUNT | UF_DONT_EXPIRE_PASSWD;
487 usr->usri1_full_name[0] = 0;
488 usr->usri1_user_id = 500;
489 usr->usri1_next_index = 0;
492 /************************************************************
493 * ACCESS_QueryGuestDisplayInformation
495 * Creates a buffer with information for the Guest User
497 static void ACCESS_QueryGuestDisplayInformation(PNET_DISPLAY_USER *buf, PDWORD pdwSize)
499 static const WCHAR sGuestUserName[] = {
500 'G','u','e','s','t',0 };
502 /* sizes of the field buffers in WCHARS */
503 int name_sz, comment_sz, full_name_sz;
504 PNET_DISPLAY_USER usr;
507 name_sz = lstrlenW(sGuestUserName);
511 *pdwSize = sizeof(NET_DISPLAY_USER);
512 *pdwSize += (name_sz + comment_sz + full_name_sz) * sizeof(WCHAR);
513 NetApiBufferAllocate(*pdwSize, (LPVOID *) buf);
516 usr->usri1_name = (LPWSTR) ((PBYTE) usr + sizeof(NET_DISPLAY_USER));
517 usr->usri1_comment = (LPWSTR) (
518 ((PBYTE) usr->usri1_name) + name_sz * sizeof(WCHAR));
519 usr->usri1_full_name = (LPWSTR) (
520 ((PBYTE) usr->usri1_comment) + comment_sz * sizeof(WCHAR));
523 lstrcpyW(usr->usri1_name, sGuestUserName);
524 usr->usri1_comment[0] = 0;
525 usr->usri1_flags = UF_ACCOUNTDISABLE | UF_SCRIPT | UF_NORMAL_ACCOUNT |
526 UF_DONT_EXPIRE_PASSWD;
527 usr->usri1_full_name[0] = 0;
528 usr->usri1_user_id = 500;
529 usr->usri1_next_index = 0;
532 /************************************************************
533 * Copies NET_DISPLAY_USER record.
535 static void ACCESS_CopyDisplayUser(const NET_DISPLAY_USER *dest, LPWSTR *dest_buf,
536 PNET_DISPLAY_USER src)
538 LPWSTR str = *dest_buf;
540 src->usri1_name = str;
541 lstrcpyW(src->usri1_name, dest->usri1_name);
543 ((PBYTE) str) + (lstrlenW(str) + 1) * sizeof(WCHAR));
545 src->usri1_comment = str;
546 lstrcpyW(src->usri1_comment, dest->usri1_comment);
548 ((PBYTE) str) + (lstrlenW(str) + 1) * sizeof(WCHAR));
550 src->usri1_flags = dest->usri1_flags;
552 src->usri1_full_name = str;
553 lstrcpyW(src->usri1_full_name, dest->usri1_full_name);
555 ((PBYTE) str) + (lstrlenW(str) + 1) * sizeof(WCHAR));
557 src->usri1_user_id = dest->usri1_user_id;
558 src->usri1_next_index = dest->usri1_next_index;
562 /************************************************************
563 * NetQueryDisplayInformation (NETAPI32.@)
565 * The buffer structure:
566 * - array of fixed size record of the level type
567 * - strings, referenced by the record of the level type
569 NET_API_STATUS WINAPI
570 NetQueryDisplayInformation(
571 LPCWSTR ServerName, DWORD Level, DWORD Index, DWORD EntriesRequested,
572 DWORD PreferredMaximumLength, LPDWORD ReturnedEntryCount,
575 TRACE("(%s, %d, %d, %d, %d, %p, %p)\n", debugstr_w(ServerName),
576 Level, Index, EntriesRequested, PreferredMaximumLength,
577 ReturnedEntryCount, SortedBuffer);
579 if(!NETAPI_IsLocalComputer(ServerName))
581 FIXME("Only implemented on local computer, but requested for "
582 "remote server %s\n", debugstr_w(ServerName));
583 return ERROR_ACCESS_DENIED;
591 PNET_DISPLAY_USER inf;
592 /* current available strings buffer */
594 PNET_DISPLAY_USER admin, guest;
595 DWORD admin_size, guest_size;
599 /* sizes of the field buffers in WCHARS */
600 int name_sz, comment_sz, full_name_sz;
602 /* number of the records, returned in SortedBuffer
603 3 - for current user, Administrator and Guest users
607 FIXME("Level %d partially implemented\n", Level);
608 *ReturnedEntryCount = records;
614 NetApiBufferAllocate(dwSize, (LPVOID *) &name);
615 if (!GetUserNameW(name, &dwSize))
617 NetApiBufferFree(name);
618 return ERROR_ACCESS_DENIED;
621 ACCESS_QueryAdminDisplayInformation(&admin, &admin_size);
622 ACCESS_QueryGuestDisplayInformation(&guest, &guest_size);
625 dwSize = sizeof(NET_DISPLAY_USER) * records;
626 dwSize += (name_sz + comment_sz + full_name_sz) * sizeof(WCHAR);
628 NetApiBufferAllocate(dwSize +
629 admin_size - sizeof(NET_DISPLAY_USER) +
630 guest_size - sizeof(NET_DISPLAY_USER),
632 inf = (PNET_DISPLAY_USER) *SortedBuffer;
633 str = (LPWSTR) ((PBYTE) inf + sizeof(NET_DISPLAY_USER) * records);
634 inf->usri1_name = str;
636 ((PBYTE) str) + name_sz * sizeof(WCHAR));
637 inf->usri1_comment = str;
639 ((PBYTE) str) + comment_sz * sizeof(WCHAR));
640 inf->usri1_full_name = str;
642 ((PBYTE) str) + full_name_sz * sizeof(WCHAR));
645 lstrcpyW(inf->usri1_name, name);
646 NetApiBufferFree(name);
647 inf->usri1_comment[0] = 0;
649 UF_SCRIPT | UF_NORMAL_ACCOUNT | UF_DONT_EXPIRE_PASSWD;
650 inf->usri1_full_name[0] = 0;
651 inf->usri1_user_id = 0;
652 inf->usri1_next_index = 0;
655 ACCESS_CopyDisplayUser(admin, &str, inf);
656 NetApiBufferFree(admin);
659 ACCESS_CopyDisplayUser(guest, &str, inf);
660 NetApiBufferFree(guest);
667 FIXME("Level %d is not implemented\n", Level);
672 TRACE("Invalid level %d is specified\n", Level);
673 return ERROR_INVALID_LEVEL;
678 /************************************************************
679 * NetGetDCName (NETAPI32.@)
681 * Return the name of the primary domain controller (PDC)
684 NET_API_STATUS WINAPI
685 NetGetDCName(LPCWSTR servername, LPCWSTR domainname, LPBYTE *bufptr)
687 FIXME("(%s, %s, %p) stub!\n", debugstr_w(servername),
688 debugstr_w(domainname), bufptr);
689 return NERR_DCNotFound; /* say we can't find a domain controller */
692 /************************************************************
693 * NetGroupEnum (NETAPI32.@)
696 NET_API_STATUS WINAPI
697 NetGroupEnum(LPCWSTR servername, DWORD level, LPBYTE *bufptr, DWORD prefmaxlen,
698 LPDWORD entriesread, LPDWORD totalentries, LPDWORD resume_handle)
700 FIXME("(%s, %d, %p, %d, %p, %p, %p) stub!\n", debugstr_w(servername),
701 level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
702 return ERROR_ACCESS_DENIED;
705 /******************************************************************************
706 * NetUserModalsGet (NETAPI32.@)
708 * Retrieves global information for all users and global groups in the security
712 * szServer [I] Specifies the DNS or the NetBIOS name of the remote server
713 * on which the function is to execute.
714 * level [I] Information level of the data.
715 * 0 Return global passwords parameters. bufptr points to a
716 * USER_MODALS_INFO_0 struct.
717 * 1 Return logon server and domain controller information. bufptr
718 * points to a USER_MODALS_INFO_1 struct.
719 * 2 Return domain name and identifier. bufptr points to a
720 * USER_MODALS_INFO_2 struct.
721 * 3 Return lockout information. bufptr points to a USER_MODALS_INFO_3
723 * pbuffer [I] Buffer that receives the data.
726 * Success: NERR_Success.
728 * ERROR_ACCESS_DENIED - the user does not have access to the info.
729 * NERR_InvalidComputer - computer name is invalid.
731 NET_API_STATUS WINAPI NetUserModalsGet(
732 LPCWSTR szServer, DWORD level, LPBYTE *pbuffer)
734 TRACE("(%s %d %p)\n", debugstr_w(szServer), level, pbuffer);
739 /* return global passwords parameters */
740 FIXME("level 0 not implemented!\n");
742 return NERR_InternalError;
744 /* return logon server and domain controller info */
745 FIXME("level 1 not implemented!\n");
747 return NERR_InternalError;
750 /* return domain name and identifier */
751 PUSER_MODALS_INFO_2 umi;
752 LSA_HANDLE policyHandle;
753 LSA_OBJECT_ATTRIBUTES objectAttributes;
754 PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo;
756 PSID domainIdentifier = NULL;
759 ZeroMemory(&objectAttributes, sizeof(objectAttributes));
760 objectAttributes.Length = sizeof(objectAttributes);
762 ntStatus = LsaOpenPolicy(NULL, &objectAttributes,
763 POLICY_VIEW_LOCAL_INFORMATION,
765 if (ntStatus != STATUS_SUCCESS)
767 WARN("LsaOpenPolicy failed with NT status %x\n",
768 LsaNtStatusToWinError(ntStatus));
772 ntStatus = LsaQueryInformationPolicy(policyHandle,
773 PolicyAccountDomainInformation,
774 (PVOID *)&domainInfo);
775 if (ntStatus != STATUS_SUCCESS)
777 WARN("LsaQueryInformationPolicy failed with NT status %x\n",
778 LsaNtStatusToWinError(ntStatus));
779 LsaClose(policyHandle);
783 domainIdentifier = domainInfo->DomainSid;
784 domainNameLen = lstrlenW(domainInfo->DomainName.Buffer) + 1;
785 LsaClose(policyHandle);
787 ntStatus = NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2) +
788 GetLengthSid(domainIdentifier) +
789 domainNameLen * sizeof(WCHAR),
792 if (ntStatus != NERR_Success)
794 WARN("NetApiBufferAllocate() failed\n");
795 LsaFreeMemory(domainInfo);
799 umi = (USER_MODALS_INFO_2 *) *pbuffer;
800 umi->usrmod2_domain_id = (PSID)(*pbuffer +
801 sizeof(USER_MODALS_INFO_2));
802 umi->usrmod2_domain_name = (LPWSTR)(*pbuffer +
803 sizeof(USER_MODALS_INFO_2) + GetLengthSid(domainIdentifier));
805 lstrcpynW(umi->usrmod2_domain_name,
806 domainInfo->DomainName.Buffer,
808 CopySid(GetLengthSid(domainIdentifier), umi->usrmod2_domain_id,
811 LsaFreeMemory(domainInfo);
816 /* return lockout information */
817 FIXME("level 3 not implemented!\n");
819 return NERR_InternalError;
821 TRACE("Invalid level %d is specified\n", level);
823 return ERROR_INVALID_LEVEL;
829 /******************************************************************************
830 * NetUserChangePassword (NETAPI32.@)
832 * domainname [I] Optional. Domain on which the user resides or the logon
833 * domain of the current user if NULL.
834 * username [I] Optional. Username to change the password for or the name
835 * of the current user if NULL.
836 * oldpassword [I] The user's current password.
837 * newpassword [I] The password that the user will be changed to using.
840 * Success: NERR_Success.
841 * Failure: NERR_* failure code or win error code.
844 NET_API_STATUS WINAPI NetUserChangePassword(LPCWSTR domainname, LPCWSTR username,
845 LPCWSTR oldpassword, LPCWSTR newpassword)
847 struct sam_user *user;
849 TRACE("(%s, %s, ..., ...)\n", debugstr_w(domainname), debugstr_w(username));
852 FIXME("Ignoring domainname %s.\n", debugstr_w(domainname));
854 if((user = NETAPI_FindUser(username)) == NULL)
855 return NERR_UserNotFound;
857 if(lstrcmpW(user->user_password, oldpassword) != 0)
858 return ERROR_INVALID_PASSWORD;
860 if(lstrlenW(newpassword) > PWLEN)
861 return ERROR_PASSWORD_RESTRICTION;
863 lstrcpyW(user->user_password, newpassword);
868 NET_API_STATUS WINAPI NetUseAdd(LMSTR servername, DWORD level, LPBYTE bufptr, LPDWORD parm_err)
870 FIXME("%s %d %p %p stub\n", debugstr_w(servername), level, bufptr, parm_err);