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 const WCHAR sAdminUserName
[] = {'A','d','m','i','n','i','s','t','r','a','t',
63 static const WCHAR sGuestUserName
[] = {'G','u','e','s','t',0};
65 static struct list user_list
= LIST_INIT( user_list
);
67 BOOL
NETAPI_IsLocalComputer(LPCWSTR ServerName
);
69 /************************************************************
70 * NETAPI_ValidateServername
72 * Validates server name
74 static NET_API_STATUS
NETAPI_ValidateServername(LPCWSTR ServerName
)
78 if (ServerName
[0] == 0)
79 return ERROR_BAD_NETPATH
;
81 ((ServerName
[0] == '\\') &&
82 (ServerName
[1] != '\\'))
84 ((ServerName
[0] == '\\') &&
85 (ServerName
[1] == '\\') &&
88 return ERROR_INVALID_NAME
;
93 /************************************************************
96 * Looks for a user in the user database.
97 * Returns a pointer to the entry in the user list when the user
98 * is found, NULL otherwise.
100 static struct sam_user
* NETAPI_FindUser(LPCWSTR UserName
)
102 struct sam_user
*user
;
104 LIST_FOR_EACH_ENTRY(user
, &user_list
, struct sam_user
, entry
)
106 if(lstrcmpW(user
->user_name
, UserName
) == 0)
112 /************************************************************
113 * NetUserAdd (NETAPI32.@)
115 NET_API_STATUS WINAPI
NetUserAdd(LPCWSTR servername
,
116 DWORD level
, LPBYTE bufptr
, LPDWORD parm_err
)
118 NET_API_STATUS status
;
119 struct sam_user
* su
= NULL
;
121 FIXME("(%s, %d, %p, %p) stub!\n", debugstr_w(servername
), level
, bufptr
, parm_err
);
123 if((status
= NETAPI_ValidateServername(servername
)) != NERR_Success
)
128 /* Level 3 and 4 are identical for the purposes of NetUserAdd */
131 FIXME("Level 3 and 4 not implemented.\n");
134 FIXME("Level 2 not implemented.\n");
138 PUSER_INFO_1 ui
= (PUSER_INFO_1
) bufptr
;
139 su
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct sam_user
));
142 status
= NERR_InternalError
;
146 if(lstrlenW(ui
->usri1_name
) > LM20_UNLEN
)
148 status
= NERR_BadUsername
;
152 /*FIXME: do other checks for a valid username */
153 lstrcpyW(su
->user_name
, ui
->usri1_name
);
155 if(lstrlenW(ui
->usri1_password
) > PWLEN
)
157 /* Always return PasswordTooShort on invalid passwords. */
158 status
= NERR_PasswordTooShort
;
161 lstrcpyW(su
->user_password
, ui
->usri1_password
);
163 su
->sec_since_passwd_change
= ui
->usri1_password_age
;
164 su
->user_priv
= ui
->usri1_priv
;
165 su
->user_flags
= ui
->usri1_flags
;
167 /*FIXME: set the other LPWSTRs to NULL for now */
169 su
->user_comment
= NULL
;
170 su
->user_logon_script_path
= NULL
;
172 list_add_head(&user_list
, &su
->entry
);
176 TRACE("Invalid level %d specified.\n", level
);
177 status
= ERROR_INVALID_LEVEL
;
183 HeapFree(GetProcessHeap(), 0, su
->home_dir
);
184 HeapFree(GetProcessHeap(), 0, su
->user_comment
);
185 HeapFree(GetProcessHeap(), 0, su
->user_logon_script_path
);
186 HeapFree(GetProcessHeap(), 0, su
);
191 /************************************************************
192 * NetUserDel (NETAPI32.@)
194 NET_API_STATUS WINAPI
NetUserDel(LPCWSTR servername
, LPCWSTR username
)
196 NET_API_STATUS status
;
197 struct sam_user
*user
;
199 TRACE("(%s, %s)\n", debugstr_w(servername
), debugstr_w(username
));
201 if((status
= NETAPI_ValidateServername(servername
))!= NERR_Success
)
204 if ((user
= NETAPI_FindUser(username
)) == NULL
)
205 return NERR_UserNotFound
;
207 list_remove(&user
->entry
);
209 HeapFree(GetProcessHeap(), 0, user
->home_dir
);
210 HeapFree(GetProcessHeap(), 0, user
->user_comment
);
211 HeapFree(GetProcessHeap(), 0, user
->user_logon_script_path
);
212 HeapFree(GetProcessHeap(), 0, user
);
217 /************************************************************
218 * NetUserGetInfo (NETAPI32.@)
220 NET_API_STATUS WINAPI
221 NetUserGetInfo(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
224 NET_API_STATUS status
;
225 TRACE("(%s, %s, %d, %p)\n", debugstr_w(servername
), debugstr_w(username
),
227 status
= NETAPI_ValidateServername(servername
);
228 if (status
!= NERR_Success
)
231 if(!NETAPI_IsLocalComputer(servername
))
233 FIXME("Only implemented for local computer, but remote server"
234 "%s was requested.\n", debugstr_w(servername
));
235 return NERR_InvalidComputer
;
238 if(!NETAPI_FindUser(username
))
240 TRACE("User %s is unknown.\n", debugstr_w(username
));
241 return NERR_UserNotFound
;
251 name_sz
= lstrlenW(username
) + 1;
254 NetApiBufferAllocate(sizeof(USER_INFO_0
) + name_sz
* sizeof(WCHAR
),
257 ui
= (PUSER_INFO_0
) *bufptr
;
258 ui
->usri0_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_0
));
261 lstrcpyW(ui
->usri0_name
, username
);
269 NET_API_STATUS status
;
270 /* sizes of the field buffers in WCHARS */
271 int name_sz
, comment_sz
, usr_comment_sz
, full_name_sz
;
278 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
279 if (status
!= NERR_Success
)
281 NetApiBufferFree(ui0
);
284 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
287 NetApiBufferAllocate(sizeof(USER_INFO_10
) +
288 (name_sz
+ comment_sz
+ usr_comment_sz
+
289 full_name_sz
) * sizeof(WCHAR
),
291 ui
= (PUSER_INFO_10
) *bufptr
;
292 ui
->usri10_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_10
));
293 ui
->usri10_comment
= (LPWSTR
) (
294 ((PBYTE
) ui
->usri10_name
) + name_sz
* sizeof(WCHAR
));
295 ui
->usri10_usr_comment
= (LPWSTR
) (
296 ((PBYTE
) ui
->usri10_comment
) + comment_sz
* sizeof(WCHAR
));
297 ui
->usri10_full_name
= (LPWSTR
) (
298 ((PBYTE
) ui
->usri10_usr_comment
) + usr_comment_sz
* sizeof(WCHAR
));
301 lstrcpyW(ui
->usri10_name
, ui0
->usri0_name
);
302 NetApiBufferFree(ui0
);
303 ui
->usri10_comment
[0] = 0;
304 ui
->usri10_usr_comment
[0] = 0;
305 ui
->usri10_full_name
[0] = 0;
311 static const WCHAR homedirW
[] = {'H','O','M','E',0};
314 NET_API_STATUS status
;
315 /* sizes of the field buffers in WCHARS */
316 int name_sz
, password_sz
, home_dir_sz
, comment_sz
, script_path_sz
;
318 password_sz
= 1; /* not filled out for security reasons for NetUserGetInfo*/
323 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
324 if (status
!= NERR_Success
)
326 NetApiBufferFree(ui0
);
329 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
330 home_dir_sz
= GetEnvironmentVariableW(homedirW
, NULL
,0);
332 NetApiBufferAllocate(sizeof(USER_INFO_1
) +
333 (name_sz
+ password_sz
+ home_dir_sz
+
334 comment_sz
+ script_path_sz
) * sizeof(WCHAR
),
337 ui
= (PUSER_INFO_1
) *bufptr
;
338 ui
->usri1_name
= (LPWSTR
) (ui
+ 1);
339 ui
->usri1_password
= ui
->usri1_name
+ name_sz
;
340 ui
->usri1_home_dir
= ui
->usri1_password
+ password_sz
;
341 ui
->usri1_comment
= ui
->usri1_home_dir
+ home_dir_sz
;
342 ui
->usri1_script_path
= ui
->usri1_comment
+ comment_sz
;
344 lstrcpyW(ui
->usri1_name
, ui0
->usri0_name
);
345 NetApiBufferFree(ui0
);
346 ui
->usri1_password
[0] = 0;
347 ui
->usri1_password_age
= 0;
349 GetEnvironmentVariableW(homedirW
, ui
->usri1_home_dir
,home_dir_sz
);
350 ui
->usri1_comment
[0] = 0;
352 ui
->usri1_script_path
[0] = 0;
382 FIXME("Level %d is not implemented\n", level
);
383 return NERR_InternalError
;
386 TRACE("Invalid level %d is specified\n", level
);
387 return ERROR_INVALID_LEVEL
;
392 /************************************************************
393 * NetUserGetLocalGroups (NETAPI32.@)
395 NET_API_STATUS WINAPI
396 NetUserGetLocalGroups(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
397 DWORD flags
, LPBYTE
* bufptr
, DWORD prefmaxlen
,
398 LPDWORD entriesread
, LPDWORD totalentries
)
400 NET_API_STATUS status
;
402 FIXME("(%s, %s, %d, %08x, %p %d, %p, %p) stub!\n",
403 debugstr_w(servername
), debugstr_w(username
), level
, flags
, bufptr
,
404 prefmaxlen
, entriesread
, totalentries
);
406 status
= NETAPI_ValidateServername(servername
);
407 if (status
!= NERR_Success
)
410 if (!NETAPI_FindUser(username
))
411 return NERR_UserNotFound
;
413 if (bufptr
) *bufptr
= NULL
;
414 if (entriesread
) *entriesread
= 0;
415 if (totalentries
) *totalentries
= 0;
420 /************************************************************
421 * NetUserEnum (NETAPI32.@)
423 NET_API_STATUS WINAPI
424 NetUserEnum(LPCWSTR servername
, DWORD level
, DWORD filter
, LPBYTE
* bufptr
,
425 DWORD prefmaxlen
, LPDWORD entriesread
, LPDWORD totalentries
,
426 LPDWORD resume_handle
)
428 FIXME("(%s,%d, 0x%d,%p,%d,%p,%p,%p) stub!\n", debugstr_w(servername
), level
,
429 filter
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resume_handle
);
431 return ERROR_ACCESS_DENIED
;
434 /************************************************************
435 * ACCESS_QueryAdminDisplayInformation
437 * Creates a buffer with information for the Admin User
439 static void ACCESS_QueryAdminDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
441 static const WCHAR sAdminUserName
[] = {
442 'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
444 /* sizes of the field buffers in WCHARS */
445 int name_sz
, comment_sz
, full_name_sz
;
446 PNET_DISPLAY_USER usr
;
449 name_sz
= lstrlenW(sAdminUserName
);
453 *pdwSize
= sizeof(NET_DISPLAY_USER
);
454 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
455 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
458 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
459 usr
->usri1_comment
= (LPWSTR
) (
460 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
461 usr
->usri1_full_name
= (LPWSTR
) (
462 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
465 lstrcpyW(usr
->usri1_name
, sAdminUserName
);
466 usr
->usri1_comment
[0] = 0;
467 usr
->usri1_flags
= UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
468 usr
->usri1_full_name
[0] = 0;
469 usr
->usri1_user_id
= 500;
470 usr
->usri1_next_index
= 0;
473 /************************************************************
474 * ACCESS_QueryGuestDisplayInformation
476 * Creates a buffer with information for the Guest User
478 static void ACCESS_QueryGuestDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
480 static const WCHAR sGuestUserName
[] = {
481 'G','u','e','s','t',0 };
483 /* sizes of the field buffers in WCHARS */
484 int name_sz
, comment_sz
, full_name_sz
;
485 PNET_DISPLAY_USER usr
;
488 name_sz
= lstrlenW(sGuestUserName
);
492 *pdwSize
= sizeof(NET_DISPLAY_USER
);
493 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
494 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
497 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
498 usr
->usri1_comment
= (LPWSTR
) (
499 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
500 usr
->usri1_full_name
= (LPWSTR
) (
501 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
504 lstrcpyW(usr
->usri1_name
, sGuestUserName
);
505 usr
->usri1_comment
[0] = 0;
506 usr
->usri1_flags
= UF_ACCOUNTDISABLE
| UF_SCRIPT
| UF_NORMAL_ACCOUNT
|
507 UF_DONT_EXPIRE_PASSWD
;
508 usr
->usri1_full_name
[0] = 0;
509 usr
->usri1_user_id
= 500;
510 usr
->usri1_next_index
= 0;
513 /************************************************************
514 * Copies NET_DISPLAY_USER record.
516 static void ACCESS_CopyDisplayUser(PNET_DISPLAY_USER dest
, LPWSTR
*dest_buf
,
517 PNET_DISPLAY_USER src
)
519 LPWSTR str
= *dest_buf
;
521 src
->usri1_name
= str
;
522 lstrcpyW(src
->usri1_name
, dest
->usri1_name
);
524 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
526 src
->usri1_comment
= str
;
527 lstrcpyW(src
->usri1_comment
, dest
->usri1_comment
);
529 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
531 src
->usri1_flags
= dest
->usri1_flags
;
533 src
->usri1_full_name
= str
;
534 lstrcpyW(src
->usri1_full_name
, dest
->usri1_full_name
);
536 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
538 src
->usri1_user_id
= dest
->usri1_user_id
;
539 src
->usri1_next_index
= dest
->usri1_next_index
;
543 /************************************************************
544 * NetQueryDisplayInformation (NETAPI32.@)
546 * The buffer structure:
547 * - array of fixed size record of the level type
548 * - strings, referenced by the record of the level type
550 NET_API_STATUS WINAPI
551 NetQueryDisplayInformation(
552 LPCWSTR ServerName
, DWORD Level
, DWORD Index
, DWORD EntriesRequested
,
553 DWORD PreferredMaximumLength
, LPDWORD ReturnedEntryCount
,
556 TRACE("(%s, %d, %d, %d, %d, %p, %p)\n", debugstr_w(ServerName
),
557 Level
, Index
, EntriesRequested
, PreferredMaximumLength
,
558 ReturnedEntryCount
, SortedBuffer
);
560 if(!NETAPI_IsLocalComputer(ServerName
))
562 FIXME("Only implemented on local computer, but requested for "
563 "remote server %s\n", debugstr_w(ServerName
));
564 return ERROR_ACCESS_DENIED
;
572 PNET_DISPLAY_USER inf
;
573 /* current available strings buffer */
575 PNET_DISPLAY_USER admin
, guest
;
576 DWORD admin_size
, guest_size
;
580 /* sizes of the field buffers in WCHARS */
581 int name_sz
, comment_sz
, full_name_sz
;
583 /* number of the records, returned in SortedBuffer
584 3 - for current user, Administrator and Guest users
588 FIXME("Level %d partially implemented\n", Level
);
589 *ReturnedEntryCount
= records
;
595 NetApiBufferAllocate(dwSize
, (LPVOID
*) &name
);
596 if (!GetUserNameW(name
, &dwSize
))
598 NetApiBufferFree(name
);
599 return ERROR_ACCESS_DENIED
;
602 ACCESS_QueryAdminDisplayInformation(&admin
, &admin_size
);
603 ACCESS_QueryGuestDisplayInformation(&guest
, &guest_size
);
606 dwSize
= sizeof(NET_DISPLAY_USER
) * records
;
607 dwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
609 NetApiBufferAllocate(dwSize
+
610 admin_size
- sizeof(NET_DISPLAY_USER
) +
611 guest_size
- sizeof(NET_DISPLAY_USER
),
612 (LPVOID
*) SortedBuffer
);
613 inf
= (PNET_DISPLAY_USER
) *SortedBuffer
;
614 str
= (LPWSTR
) ((PBYTE
) inf
+ sizeof(NET_DISPLAY_USER
) * records
);
615 inf
->usri1_name
= str
;
617 ((PBYTE
) str
) + name_sz
* sizeof(WCHAR
));
618 inf
->usri1_comment
= str
;
620 ((PBYTE
) str
) + comment_sz
* sizeof(WCHAR
));
621 inf
->usri1_full_name
= str
;
623 ((PBYTE
) str
) + full_name_sz
* sizeof(WCHAR
));
626 lstrcpyW(inf
->usri1_name
, name
);
627 NetApiBufferFree(name
);
628 inf
->usri1_comment
[0] = 0;
630 UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
631 inf
->usri1_full_name
[0] = 0;
632 inf
->usri1_user_id
= 0;
633 inf
->usri1_next_index
= 0;
636 ACCESS_CopyDisplayUser(admin
, &str
, inf
);
637 NetApiBufferFree(admin
);
640 ACCESS_CopyDisplayUser(guest
, &str
, inf
);
641 NetApiBufferFree(guest
);
648 FIXME("Level %d is not implemented\n", Level
);
653 TRACE("Invalid level %d is specified\n", Level
);
654 return ERROR_INVALID_LEVEL
;
659 /************************************************************
660 * NetGetDCName (NETAPI32.@)
662 * Return the name of the primary domain controller (PDC)
665 NET_API_STATUS WINAPI
666 NetGetDCName(LPCWSTR servername
, LPCWSTR domainname
, LPBYTE
*bufptr
)
668 FIXME("(%s, %s, %p) stub!\n", debugstr_w(servername
),
669 debugstr_w(domainname
), bufptr
);
670 return NERR_DCNotFound
; /* say we can't find a domain controller */
674 /******************************************************************************
675 * NetUserModalsGet (NETAPI32.@)
677 * Retrieves global information for all users and global groups in the security
681 * szServer [I] Specifies the DNS or the NetBIOS name of the remote server
682 * on which the function is to execute.
683 * level [I] Information level of the data.
684 * 0 Return global passwords parameters. bufptr points to a
685 * USER_MODALS_INFO_0 struct.
686 * 1 Return logon server and domain controller information. bufptr
687 * points to a USER_MODALS_INFO_1 struct.
688 * 2 Return domain name and identifier. bufptr points to a
689 * USER_MODALS_INFO_2 struct.
690 * 3 Return lockout information. bufptr points to a USER_MODALS_INFO_3
692 * pbuffer [I] Buffer that receives the data.
695 * Success: NERR_Success.
697 * ERROR_ACCESS_DENIED - the user does not have access to the info.
698 * NERR_InvalidComputer - computer name is invalid.
700 NET_API_STATUS WINAPI
NetUserModalsGet(
701 LPCWSTR szServer
, DWORD level
, LPBYTE
*pbuffer
)
703 TRACE("(%s %d %p)\n", debugstr_w(szServer
), level
, pbuffer
);
708 /* return global passwords parameters */
709 FIXME("level 0 not implemented!\n");
711 return NERR_InternalError
;
713 /* return logon server and domain controller info */
714 FIXME("level 1 not implemented!\n");
716 return NERR_InternalError
;
719 /* return domain name and identifier */
720 PUSER_MODALS_INFO_2 umi
;
721 LSA_HANDLE policyHandle
;
722 LSA_OBJECT_ATTRIBUTES objectAttributes
;
723 PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo
;
725 PSID domainIdentifier
= NULL
;
728 ZeroMemory(&objectAttributes
, sizeof(objectAttributes
));
729 objectAttributes
.Length
= sizeof(objectAttributes
);
731 ntStatus
= LsaOpenPolicy(NULL
, &objectAttributes
,
732 POLICY_VIEW_LOCAL_INFORMATION
,
734 if (ntStatus
!= STATUS_SUCCESS
)
736 WARN("LsaOpenPolicy failed with NT status %x\n",
737 LsaNtStatusToWinError(ntStatus
));
741 ntStatus
= LsaQueryInformationPolicy(policyHandle
,
742 PolicyAccountDomainInformation
,
743 (PVOID
*)&domainInfo
);
744 if (ntStatus
!= STATUS_SUCCESS
)
746 WARN("LsaQueryInformationPolicy failed with NT status %x\n",
747 LsaNtStatusToWinError(ntStatus
));
748 LsaClose(policyHandle
);
752 domainIdentifier
= domainInfo
->DomainSid
;
753 domainNameLen
= lstrlenW(domainInfo
->DomainName
.Buffer
) + 1;
754 LsaClose(policyHandle
);
756 ntStatus
= NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2
) +
757 GetLengthSid(domainIdentifier
) +
758 domainNameLen
* sizeof(WCHAR
),
761 if (ntStatus
!= NERR_Success
)
763 WARN("NetApiBufferAllocate() failed\n");
764 LsaFreeMemory(domainInfo
);
768 umi
= (USER_MODALS_INFO_2
*) *pbuffer
;
769 umi
->usrmod2_domain_id
= (PSID
)(*pbuffer
+
770 sizeof(USER_MODALS_INFO_2
));
771 umi
->usrmod2_domain_name
= (LPWSTR
)(*pbuffer
+
772 sizeof(USER_MODALS_INFO_2
) + GetLengthSid(domainIdentifier
));
774 lstrcpynW(umi
->usrmod2_domain_name
,
775 domainInfo
->DomainName
.Buffer
,
777 CopySid(GetLengthSid(domainIdentifier
), umi
->usrmod2_domain_id
,
780 LsaFreeMemory(domainInfo
);
785 /* return lockout information */
786 FIXME("level 3 not implemented!\n");
788 return NERR_InternalError
;
790 TRACE("Invalid level %d is specified\n", level
);
792 return ERROR_INVALID_LEVEL
;
798 /******************************************************************************
799 * NetUserChangePassword (NETAPI32.@)
801 * domainname [I] Optional. Domain on which the user resides or the logon
802 * domain of the current user if NULL.
803 * username [I] Optional. Username to change the password for or the name
804 * of the current user if NULL.
805 * oldpassword [I] The user's current password.
806 * newpassword [I] The password that the user will be changed to using.
809 * Success: NERR_Success.
810 * Failure: NERR_* failure code or win error code.
813 NET_API_STATUS WINAPI
NetUserChangePassword(LPCWSTR domainname
, LPCWSTR username
,
814 LPCWSTR oldpassword
, LPCWSTR newpassword
)
816 struct sam_user
*user
;
818 TRACE("(%s, %s, ..., ...)\n", debugstr_w(domainname
), debugstr_w(username
));
821 FIXME("Ignoring domainname %s.\n", debugstr_w(domainname
));
823 if((user
= NETAPI_FindUser(username
)) == NULL
)
824 return NERR_UserNotFound
;
826 if(lstrcmpW(user
->user_password
, oldpassword
) != 0)
827 return ERROR_INVALID_PASSWORD
;
829 if(lstrlenW(newpassword
) > PWLEN
)
830 return ERROR_PASSWORD_RESTRICTION
;
832 lstrcpyW(user
->user_password
, newpassword
);