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
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
35 #include "wine/list.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(netapi32
);
39 /* NOTE: So far, this is implemented to support tests that require user logins,
40 * but not designed to handle real user databases. Those should probably
41 * be synced with either the host's user database or with Samba.
43 * FIXME: The user database should hold all the information the USER_INFO_4 struct
44 * needs, but for the first try, I will just implement the USER_INFO_1 fields.
50 WCHAR user_name
[LM20_UNLEN
+1];
51 WCHAR user_password
[PWLEN
+ 1];
52 DWORD sec_since_passwd_change
;
57 LPWSTR user_logon_script_path
;
60 static const WCHAR sAdminUserName
[] = {'A','d','m','i','n','i','s','t','r','a','t',
62 static const WCHAR sGuestUserName
[] = {'G','u','e','s','t',0};
64 static struct list user_list
= LIST_INIT( user_list
);
66 BOOL
NETAPI_IsLocalComputer(LPCWSTR ServerName
);
68 /************************************************************
69 * NETAPI_ValidateServername
71 * Validates server name
73 static NET_API_STATUS
NETAPI_ValidateServername(LPCWSTR ServerName
)
77 if (ServerName
[0] == 0)
78 return ERROR_BAD_NETPATH
;
80 ((ServerName
[0] == '\\') &&
81 (ServerName
[1] != '\\'))
83 ((ServerName
[0] == '\\') &&
84 (ServerName
[1] == '\\') &&
87 return ERROR_INVALID_NAME
;
92 /************************************************************
95 * Looks for a user in the user database.
96 * Returns a pointer to the entry in the user list when the user
97 * is found, NULL otherwise.
99 static struct sam_user
* NETAPI_FindUser(LPCWSTR UserName
)
101 struct sam_user
*user
;
103 LIST_FOR_EACH_ENTRY(user
, &user_list
, struct sam_user
, entry
)
105 if(lstrcmpW(user
->user_name
, UserName
) == 0)
111 /************************************************************
112 * NetUserAdd (NETAPI32.@)
114 NET_API_STATUS WINAPI
NetUserAdd(LPCWSTR servername
,
115 DWORD level
, LPBYTE bufptr
, LPDWORD parm_err
)
117 NET_API_STATUS status
;
118 struct sam_user
* su
= NULL
;
120 FIXME("(%s, %d, %p, %p) stub!\n", debugstr_w(servername
), level
, bufptr
, parm_err
);
122 if((status
= NETAPI_ValidateServername(servername
)) != NERR_Success
)
127 /* Level 3 and 4 are identical for the purposes of NetUserAdd */
130 FIXME("Level 3 and 4 not implemented.\n");
133 FIXME("Level 2 not implemented.\n");
137 PUSER_INFO_1 ui
= (PUSER_INFO_1
) bufptr
;
138 su
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct sam_user
));
141 status
= NERR_InternalError
;
145 if(lstrlenW(ui
->usri1_name
) > LM20_UNLEN
)
147 status
= NERR_BadUsername
;
151 /*FIXME: do other checks for a valid username */
152 lstrcpyW(su
->user_name
, ui
->usri1_name
);
154 if(lstrlenW(ui
->usri1_password
) > PWLEN
)
156 /* Always return PasswordTooShort on invalid passwords. */
157 status
= NERR_PasswordTooShort
;
160 lstrcpyW(su
->user_password
, ui
->usri1_password
);
162 su
->sec_since_passwd_change
= ui
->usri1_password_age
;
163 su
->user_priv
= ui
->usri1_priv
;
164 su
->user_flags
= ui
->usri1_flags
;
166 /*FIXME: set the other LPWSTRs to NULL for now */
168 su
->user_comment
= NULL
;
169 su
->user_logon_script_path
= NULL
;
171 list_add_head(&user_list
, &su
->entry
);
175 TRACE("Invalid level %d specified.\n", level
);
176 status
= ERROR_INVALID_LEVEL
;
182 HeapFree(GetProcessHeap(), 0, su
->home_dir
);
183 HeapFree(GetProcessHeap(), 0, su
->user_comment
);
184 HeapFree(GetProcessHeap(), 0, su
->user_logon_script_path
);
185 HeapFree(GetProcessHeap(), 0, su
);
190 /************************************************************
191 * NetUserDel (NETAPI32.@)
193 NET_API_STATUS WINAPI
NetUserDel(LPCWSTR servername
, LPCWSTR username
)
195 NET_API_STATUS status
;
196 struct sam_user
*user
;
198 TRACE("(%s, %s)\n", debugstr_w(servername
), debugstr_w(username
));
200 if((status
= NETAPI_ValidateServername(servername
))!= NERR_Success
)
203 if ((user
= NETAPI_FindUser(username
)) == NULL
)
204 return NERR_UserNotFound
;
206 list_remove(&user
->entry
);
208 HeapFree(GetProcessHeap(), 0, user
->home_dir
);
209 HeapFree(GetProcessHeap(), 0, user
->user_comment
);
210 HeapFree(GetProcessHeap(), 0, user
->user_logon_script_path
);
211 HeapFree(GetProcessHeap(), 0, user
);
216 /************************************************************
217 * NetUserGetInfo (NETAPI32.@)
219 NET_API_STATUS WINAPI
220 NetUserGetInfo(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
223 NET_API_STATUS status
;
224 TRACE("(%s, %s, %d, %p)\n", debugstr_w(servername
), debugstr_w(username
),
226 status
= NETAPI_ValidateServername(servername
);
227 if (status
!= NERR_Success
)
230 if(!NETAPI_IsLocalComputer(servername
))
232 FIXME("Only implemented for local computer, but remote server"
233 "%s was requested.\n", debugstr_w(servername
));
234 return NERR_InvalidComputer
;
237 if(!NETAPI_FindUser(username
))
239 TRACE("User %s is unknown.\n", debugstr_w(username
));
240 return NERR_UserNotFound
;
250 name_sz
= lstrlenW(username
) + 1;
253 NetApiBufferAllocate(sizeof(USER_INFO_0
) + name_sz
* sizeof(WCHAR
),
256 ui
= (PUSER_INFO_0
) *bufptr
;
257 ui
->usri0_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_0
));
260 lstrcpyW(ui
->usri0_name
, username
);
268 NET_API_STATUS status
;
269 /* sizes of the field buffers in WCHARS */
270 int name_sz
, comment_sz
, usr_comment_sz
, full_name_sz
;
277 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
278 if (status
!= NERR_Success
)
280 NetApiBufferFree(ui0
);
283 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
286 NetApiBufferAllocate(sizeof(USER_INFO_10
) +
287 (name_sz
+ comment_sz
+ usr_comment_sz
+
288 full_name_sz
) * sizeof(WCHAR
),
290 ui
= (PUSER_INFO_10
) *bufptr
;
291 ui
->usri10_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_10
));
292 ui
->usri10_comment
= (LPWSTR
) (
293 ((PBYTE
) ui
->usri10_name
) + name_sz
* sizeof(WCHAR
));
294 ui
->usri10_usr_comment
= (LPWSTR
) (
295 ((PBYTE
) ui
->usri10_comment
) + comment_sz
* sizeof(WCHAR
));
296 ui
->usri10_full_name
= (LPWSTR
) (
297 ((PBYTE
) ui
->usri10_usr_comment
) + usr_comment_sz
* sizeof(WCHAR
));
300 lstrcpyW(ui
->usri10_name
, ui0
->usri0_name
);
301 NetApiBufferFree(ui0
);
302 ui
->usri10_comment
[0] = 0;
303 ui
->usri10_usr_comment
[0] = 0;
304 ui
->usri10_full_name
[0] = 0;
310 static const WCHAR homedirW
[] = {'H','O','M','E',0};
313 NET_API_STATUS status
;
314 /* sizes of the field buffers in WCHARS */
315 int name_sz
, password_sz
, home_dir_sz
, comment_sz
, script_path_sz
;
317 password_sz
= 1; /* not filled out for security reasons for NetUserGetInfo*/
322 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
323 if (status
!= NERR_Success
)
325 NetApiBufferFree(ui0
);
328 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
329 home_dir_sz
= GetEnvironmentVariableW(homedirW
, NULL
,0);
331 NetApiBufferAllocate(sizeof(USER_INFO_1
) +
332 (name_sz
+ password_sz
+ home_dir_sz
+
333 comment_sz
+ script_path_sz
) * sizeof(WCHAR
),
336 ui
= (PUSER_INFO_1
) *bufptr
;
337 ui
->usri1_name
= (LPWSTR
) (ui
+ 1);
338 ui
->usri1_password
= ui
->usri1_name
+ name_sz
;
339 ui
->usri1_home_dir
= ui
->usri1_password
+ password_sz
;
340 ui
->usri1_comment
= ui
->usri1_home_dir
+ home_dir_sz
;
341 ui
->usri1_script_path
= ui
->usri1_comment
+ comment_sz
;
343 lstrcpyW(ui
->usri1_name
, ui0
->usri0_name
);
344 NetApiBufferFree(ui0
);
345 ui
->usri1_password
[0] = 0;
346 ui
->usri1_password_age
= 0;
348 GetEnvironmentVariableW(homedirW
, ui
->usri1_home_dir
,home_dir_sz
);
349 ui
->usri1_comment
[0] = 0;
351 ui
->usri1_script_path
[0] = 0;
381 FIXME("Level %d is not implemented\n", level
);
382 return NERR_InternalError
;
385 TRACE("Invalid level %d is specified\n", level
);
386 return ERROR_INVALID_LEVEL
;
391 /************************************************************
392 * NetUserGetLocalGroups (NETAPI32.@)
394 NET_API_STATUS WINAPI
395 NetUserGetLocalGroups(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
396 DWORD flags
, LPBYTE
* bufptr
, DWORD prefmaxlen
,
397 LPDWORD entriesread
, LPDWORD totalentries
)
399 NET_API_STATUS status
;
401 FIXME("(%s, %s, %d, %08x, %p %d, %p, %p) stub!\n",
402 debugstr_w(servername
), debugstr_w(username
), level
, flags
, bufptr
,
403 prefmaxlen
, entriesread
, totalentries
);
405 status
= NETAPI_ValidateServername(servername
);
406 if (status
!= NERR_Success
)
409 if (!NETAPI_FindUser(username
))
410 return NERR_UserNotFound
;
412 if (bufptr
) *bufptr
= NULL
;
413 if (entriesread
) *entriesread
= 0;
414 if (totalentries
) *totalentries
= 0;
419 /************************************************************
420 * NetUserEnum (NETAPI32.@)
422 NET_API_STATUS WINAPI
423 NetUserEnum(LPCWSTR servername
, DWORD level
, DWORD filter
, LPBYTE
* bufptr
,
424 DWORD prefmaxlen
, LPDWORD entriesread
, LPDWORD totalentries
,
425 LPDWORD resume_handle
)
427 FIXME("(%s,%d, 0x%d,%p,%d,%p,%p,%p) stub!\n", debugstr_w(servername
), level
,
428 filter
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resume_handle
);
430 return ERROR_ACCESS_DENIED
;
433 /************************************************************
434 * ACCESS_QueryAdminDisplayInformation
436 * Creates a buffer with information for the Admin User
438 static void ACCESS_QueryAdminDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
440 static const WCHAR sAdminUserName
[] = {
441 'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
443 /* sizes of the field buffers in WCHARS */
444 int name_sz
, comment_sz
, full_name_sz
;
445 PNET_DISPLAY_USER usr
;
448 name_sz
= lstrlenW(sAdminUserName
);
452 *pdwSize
= sizeof(NET_DISPLAY_USER
);
453 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
454 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
457 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
458 usr
->usri1_comment
= (LPWSTR
) (
459 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
460 usr
->usri1_full_name
= (LPWSTR
) (
461 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
464 lstrcpyW(usr
->usri1_name
, sAdminUserName
);
465 usr
->usri1_comment
[0] = 0;
466 usr
->usri1_flags
= UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
467 usr
->usri1_full_name
[0] = 0;
468 usr
->usri1_user_id
= 500;
469 usr
->usri1_next_index
= 0;
472 /************************************************************
473 * ACCESS_QueryGuestDisplayInformation
475 * Creates a buffer with information for the Guest User
477 static void ACCESS_QueryGuestDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
479 static const WCHAR sGuestUserName
[] = {
480 'G','u','e','s','t',0 };
482 /* sizes of the field buffers in WCHARS */
483 int name_sz
, comment_sz
, full_name_sz
;
484 PNET_DISPLAY_USER usr
;
487 name_sz
= lstrlenW(sGuestUserName
);
491 *pdwSize
= sizeof(NET_DISPLAY_USER
);
492 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
493 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
496 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
497 usr
->usri1_comment
= (LPWSTR
) (
498 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
499 usr
->usri1_full_name
= (LPWSTR
) (
500 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
503 lstrcpyW(usr
->usri1_name
, sGuestUserName
);
504 usr
->usri1_comment
[0] = 0;
505 usr
->usri1_flags
= UF_ACCOUNTDISABLE
| UF_SCRIPT
| UF_NORMAL_ACCOUNT
|
506 UF_DONT_EXPIRE_PASSWD
;
507 usr
->usri1_full_name
[0] = 0;
508 usr
->usri1_user_id
= 500;
509 usr
->usri1_next_index
= 0;
512 /************************************************************
513 * Copies NET_DISPLAY_USER record.
515 static void ACCESS_CopyDisplayUser(PNET_DISPLAY_USER dest
, LPWSTR
*dest_buf
,
516 PNET_DISPLAY_USER src
)
518 LPWSTR str
= *dest_buf
;
520 src
->usri1_name
= str
;
521 lstrcpyW(src
->usri1_name
, dest
->usri1_name
);
523 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
525 src
->usri1_comment
= str
;
526 lstrcpyW(src
->usri1_comment
, dest
->usri1_comment
);
528 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
530 src
->usri1_flags
= dest
->usri1_flags
;
532 src
->usri1_full_name
= str
;
533 lstrcpyW(src
->usri1_full_name
, dest
->usri1_full_name
);
535 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
537 src
->usri1_user_id
= dest
->usri1_user_id
;
538 src
->usri1_next_index
= dest
->usri1_next_index
;
542 /************************************************************
543 * NetQueryDisplayInformation (NETAPI32.@)
545 * The buffer structure:
546 * - array of fixed size record of the level type
547 * - strings, referenced by the record of the level type
549 NET_API_STATUS WINAPI
550 NetQueryDisplayInformation(
551 LPCWSTR ServerName
, DWORD Level
, DWORD Index
, DWORD EntriesRequested
,
552 DWORD PreferredMaximumLength
, LPDWORD ReturnedEntryCount
,
555 TRACE("(%s, %d, %d, %d, %d, %p, %p)\n", debugstr_w(ServerName
),
556 Level
, Index
, EntriesRequested
, PreferredMaximumLength
,
557 ReturnedEntryCount
, SortedBuffer
);
559 if(!NETAPI_IsLocalComputer(ServerName
))
561 FIXME("Only implemented on local computer, but requested for "
562 "remote server %s\n", debugstr_w(ServerName
));
563 return ERROR_ACCESS_DENIED
;
571 PNET_DISPLAY_USER inf
;
572 /* current available strings buffer */
574 PNET_DISPLAY_USER admin
, guest
;
575 DWORD admin_size
, guest_size
;
579 /* sizes of the field buffers in WCHARS */
580 int name_sz
, comment_sz
, full_name_sz
;
582 /* number of the records, returned in SortedBuffer
583 3 - for current user, Administrator and Guest users
587 FIXME("Level %d partially implemented\n", Level
);
588 *ReturnedEntryCount
= records
;
594 NetApiBufferAllocate(dwSize
, (LPVOID
*) &name
);
595 if (!GetUserNameW(name
, &dwSize
))
597 NetApiBufferFree(name
);
598 return ERROR_ACCESS_DENIED
;
601 ACCESS_QueryAdminDisplayInformation(&admin
, &admin_size
);
602 ACCESS_QueryGuestDisplayInformation(&guest
, &guest_size
);
605 dwSize
= sizeof(NET_DISPLAY_USER
) * records
;
606 dwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
608 NetApiBufferAllocate(dwSize
+
609 admin_size
- sizeof(NET_DISPLAY_USER
) +
610 guest_size
- sizeof(NET_DISPLAY_USER
),
611 (LPVOID
*) SortedBuffer
);
612 inf
= (PNET_DISPLAY_USER
) *SortedBuffer
;
613 str
= (LPWSTR
) ((PBYTE
) inf
+ sizeof(NET_DISPLAY_USER
) * records
);
614 inf
->usri1_name
= str
;
616 ((PBYTE
) str
) + name_sz
* sizeof(WCHAR
));
617 inf
->usri1_comment
= str
;
619 ((PBYTE
) str
) + comment_sz
* sizeof(WCHAR
));
620 inf
->usri1_full_name
= str
;
622 ((PBYTE
) str
) + full_name_sz
* sizeof(WCHAR
));
625 lstrcpyW(inf
->usri1_name
, name
);
626 NetApiBufferFree(name
);
627 inf
->usri1_comment
[0] = 0;
629 UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
630 inf
->usri1_full_name
[0] = 0;
631 inf
->usri1_user_id
= 0;
632 inf
->usri1_next_index
= 0;
635 ACCESS_CopyDisplayUser(admin
, &str
, inf
);
636 NetApiBufferFree(admin
);
639 ACCESS_CopyDisplayUser(guest
, &str
, inf
);
640 NetApiBufferFree(guest
);
647 FIXME("Level %d is not implemented\n", Level
);
652 TRACE("Invalid level %d is specified\n", Level
);
653 return ERROR_INVALID_LEVEL
;
658 /************************************************************
659 * NetGetDCName (NETAPI32.@)
661 * Return the name of the primary domain controller (PDC)
664 NET_API_STATUS WINAPI
665 NetGetDCName(LPCWSTR servername
, LPCWSTR domainname
, LPBYTE
*bufptr
)
667 FIXME("(%s, %s, %p) stub!\n", debugstr_w(servername
),
668 debugstr_w(domainname
), bufptr
);
669 return NERR_DCNotFound
; /* say we can't find a domain controller */
673 /******************************************************************************
674 * NetUserModalsGet (NETAPI32.@)
676 * Retrieves global information for all users and global groups in the security
680 * szServer [I] Specifies the DNS or the NetBIOS name of the remote server
681 * on which the function is to execute.
682 * level [I] Information level of the data.
683 * 0 Return global passwords parameters. bufptr points to a
684 * USER_MODALS_INFO_0 struct.
685 * 1 Return logon server and domain controller information. bufptr
686 * points to a USER_MODALS_INFO_1 struct.
687 * 2 Return domain name and identifier. bufptr points to a
688 * USER_MODALS_INFO_2 struct.
689 * 3 Return lockout information. bufptr points to a USER_MODALS_INFO_3
691 * pbuffer [I] Buffer that receives the data.
694 * Success: NERR_Success.
696 * ERROR_ACCESS_DENIED - the user does not have access to the info.
697 * NERR_InvalidComputer - computer name is invalid.
699 NET_API_STATUS WINAPI
NetUserModalsGet(
700 LPCWSTR szServer
, DWORD level
, LPBYTE
*pbuffer
)
702 TRACE("(%s %d %p)\n", debugstr_w(szServer
), level
, pbuffer
);
707 /* return global passwords parameters */
708 FIXME("level 0 not implemented!\n");
710 return NERR_InternalError
;
712 /* return logon server and domain controller info */
713 FIXME("level 1 not implemented!\n");
715 return NERR_InternalError
;
718 /* return domain name and identifier */
719 PUSER_MODALS_INFO_2 umi
;
720 LSA_HANDLE policyHandle
;
721 LSA_OBJECT_ATTRIBUTES objectAttributes
;
722 PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo
;
724 PSID domainIdentifier
= NULL
;
727 ZeroMemory(&objectAttributes
, sizeof(objectAttributes
));
728 objectAttributes
.Length
= sizeof(objectAttributes
);
730 ntStatus
= LsaOpenPolicy(NULL
, &objectAttributes
,
731 POLICY_VIEW_LOCAL_INFORMATION
,
733 if (ntStatus
!= STATUS_SUCCESS
)
735 WARN("LsaOpenPolicy failed with NT status %x\n",
736 LsaNtStatusToWinError(ntStatus
));
740 ntStatus
= LsaQueryInformationPolicy(policyHandle
,
741 PolicyAccountDomainInformation
,
742 (PVOID
*)&domainInfo
);
743 if (ntStatus
!= STATUS_SUCCESS
)
745 WARN("LsaQueryInformationPolicy failed with NT status %x\n",
746 LsaNtStatusToWinError(ntStatus
));
747 LsaClose(policyHandle
);
751 domainIdentifier
= domainInfo
->DomainSid
;
752 domainNameLen
= lstrlenW(domainInfo
->DomainName
.Buffer
) + 1;
753 LsaClose(policyHandle
);
755 ntStatus
= NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2
) +
756 GetLengthSid(domainIdentifier
) +
757 domainNameLen
* sizeof(WCHAR
),
760 if (ntStatus
!= NERR_Success
)
762 WARN("NetApiBufferAllocate() failed\n");
763 LsaFreeMemory(domainInfo
);
767 umi
= (USER_MODALS_INFO_2
*) *pbuffer
;
768 umi
->usrmod2_domain_id
= (PSID
)(*pbuffer
+
769 sizeof(USER_MODALS_INFO_2
));
770 umi
->usrmod2_domain_name
= (LPWSTR
)(*pbuffer
+
771 sizeof(USER_MODALS_INFO_2
) + GetLengthSid(domainIdentifier
));
773 lstrcpynW(umi
->usrmod2_domain_name
,
774 domainInfo
->DomainName
.Buffer
,
776 CopySid(GetLengthSid(domainIdentifier
), umi
->usrmod2_domain_id
,
779 LsaFreeMemory(domainInfo
);
784 /* return lockout information */
785 FIXME("level 3 not implemented!\n");
787 return NERR_InternalError
;
789 TRACE("Invalid level %d is specified\n", level
);
791 return ERROR_INVALID_LEVEL
;
797 /******************************************************************************
798 * NetUserChangePassword (NETAPI32.@)
800 * domainname [I] Optional. Domain on which the user resides or the logon
801 * domain of the current user if NULL.
802 * username [I] Optional. Username to change the password for or the name
803 * of the current user if NULL.
804 * oldpassword [I] The user's current password.
805 * newpassword [I] The password that the user will be changed to using.
808 * Success: NERR_Success.
809 * Failure: NERR_* failure code or win error code.
812 NET_API_STATUS WINAPI
NetUserChangePassword(LPCWSTR domainname
, LPCWSTR username
,
813 LPCWSTR oldpassword
, LPCWSTR newpassword
)
815 struct sam_user
*user
;
817 TRACE("(%s, %s, ..., ...)\n", debugstr_w(domainname
), debugstr_w(username
));
820 FIXME("Ignoring domainname %s.\n", debugstr_w(domainname
));
822 if((user
= NETAPI_FindUser(username
)) == NULL
)
823 return NERR_UserNotFound
;
825 if(lstrcmpW(user
->user_password
, oldpassword
) != 0)
826 return ERROR_INVALID_PASSWORD
;
828 if(lstrlenW(newpassword
) > PWLEN
)
829 return ERROR_PASSWORD_RESTRICTION
;
831 lstrcpyW(user
->user_password
, newpassword
);