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
;
181 HeapFree(GetProcessHeap(), 0, su
);
186 /************************************************************
187 * NetUserDel (NETAPI32.@)
189 NET_API_STATUS WINAPI
NetUserDel(LPCWSTR servername
, LPCWSTR username
)
191 NET_API_STATUS status
;
192 struct sam_user
*user
;
194 TRACE("(%s, %s)\n", debugstr_w(servername
), debugstr_w(username
));
196 if((status
= NETAPI_ValidateServername(servername
))!= NERR_Success
)
199 if ((user
= NETAPI_FindUser(username
)) == NULL
)
200 return NERR_UserNotFound
;
202 list_remove(&user
->entry
);
204 HeapFree(GetProcessHeap(), 0, user
->home_dir
);
205 HeapFree(GetProcessHeap(), 0, user
->user_comment
);
206 HeapFree(GetProcessHeap(), 0, user
->user_logon_script_path
);
207 HeapFree(GetProcessHeap(), 0, user
);
212 /************************************************************
213 * NetUserGetInfo (NETAPI32.@)
215 NET_API_STATUS WINAPI
216 NetUserGetInfo(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
219 NET_API_STATUS status
;
220 TRACE("(%s, %s, %d, %p)\n", debugstr_w(servername
), debugstr_w(username
),
222 status
= NETAPI_ValidateServername(servername
);
223 if (status
!= NERR_Success
)
226 if(!NETAPI_IsLocalComputer(servername
))
228 FIXME("Only implemented for local computer, but remote server"
229 "%s was requested.\n", debugstr_w(servername
));
230 return NERR_InvalidComputer
;
233 if(!NETAPI_FindUser(username
))
235 TRACE("User %s is unknown.\n", debugstr_w(username
));
236 return NERR_UserNotFound
;
246 name_sz
= lstrlenW(username
) + 1;
249 NetApiBufferAllocate(sizeof(USER_INFO_0
) + name_sz
* sizeof(WCHAR
),
252 ui
= (PUSER_INFO_0
) *bufptr
;
253 ui
->usri0_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_0
));
256 lstrcpyW(ui
->usri0_name
, username
);
264 NET_API_STATUS status
;
265 /* sizes of the field buffers in WCHARS */
266 int name_sz
, comment_sz
, usr_comment_sz
, full_name_sz
;
273 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
274 if (status
!= NERR_Success
)
276 NetApiBufferFree(ui0
);
279 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
282 NetApiBufferAllocate(sizeof(USER_INFO_10
) +
283 (name_sz
+ comment_sz
+ usr_comment_sz
+
284 full_name_sz
) * sizeof(WCHAR
),
286 ui
= (PUSER_INFO_10
) *bufptr
;
287 ui
->usri10_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_10
));
288 ui
->usri10_comment
= (LPWSTR
) (
289 ((PBYTE
) ui
->usri10_name
) + name_sz
* sizeof(WCHAR
));
290 ui
->usri10_usr_comment
= (LPWSTR
) (
291 ((PBYTE
) ui
->usri10_comment
) + comment_sz
* sizeof(WCHAR
));
292 ui
->usri10_full_name
= (LPWSTR
) (
293 ((PBYTE
) ui
->usri10_usr_comment
) + usr_comment_sz
* sizeof(WCHAR
));
296 lstrcpyW(ui
->usri10_name
, ui0
->usri0_name
);
297 NetApiBufferFree(ui0
);
298 ui
->usri10_comment
[0] = 0;
299 ui
->usri10_usr_comment
[0] = 0;
300 ui
->usri10_full_name
[0] = 0;
306 static const WCHAR homedirW
[] = {'H','O','M','E',0};
309 NET_API_STATUS status
;
310 /* sizes of the field buffers in WCHARS */
311 int name_sz
, password_sz
, home_dir_sz
, comment_sz
, script_path_sz
;
313 password_sz
= 1; /* not filled out for security reasons for NetUserGetInfo*/
318 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
319 if (status
!= NERR_Success
)
321 NetApiBufferFree(ui0
);
324 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
325 home_dir_sz
= GetEnvironmentVariableW(homedirW
, NULL
,0);
327 NetApiBufferAllocate(sizeof(USER_INFO_1
) +
328 (name_sz
+ password_sz
+ home_dir_sz
+
329 comment_sz
+ script_path_sz
) * sizeof(WCHAR
),
332 ui
= (PUSER_INFO_1
) *bufptr
;
333 ui
->usri1_name
= (LPWSTR
) (ui
+ 1);
334 ui
->usri1_password
= ui
->usri1_name
+ name_sz
;
335 ui
->usri1_home_dir
= ui
->usri1_password
+ password_sz
;
336 ui
->usri1_comment
= ui
->usri1_home_dir
+ home_dir_sz
;
337 ui
->usri1_script_path
= ui
->usri1_comment
+ comment_sz
;
339 lstrcpyW(ui
->usri1_name
, ui0
->usri0_name
);
340 NetApiBufferFree(ui0
);
341 ui
->usri1_password
[0] = 0;
342 ui
->usri1_password_age
= 0;
344 GetEnvironmentVariableW(homedirW
, ui
->usri1_home_dir
,home_dir_sz
);
345 ui
->usri1_comment
[0] = 0;
347 ui
->usri1_script_path
[0] = 0;
377 FIXME("Level %d is not implemented\n", level
);
378 return NERR_InternalError
;
381 TRACE("Invalid level %d is specified\n", level
);
382 return ERROR_INVALID_LEVEL
;
387 /************************************************************
388 * NetUserGetLocalGroups (NETAPI32.@)
390 NET_API_STATUS WINAPI
391 NetUserGetLocalGroups(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
392 DWORD flags
, LPBYTE
* bufptr
, DWORD prefmaxlen
,
393 LPDWORD entriesread
, LPDWORD totalentries
)
395 NET_API_STATUS status
;
397 FIXME("(%s, %s, %d, %08x, %p %d, %p, %p) stub!\n",
398 debugstr_w(servername
), debugstr_w(username
), level
, flags
, bufptr
,
399 prefmaxlen
, entriesread
, totalentries
);
401 status
= NETAPI_ValidateServername(servername
);
402 if (status
!= NERR_Success
)
405 if (!NETAPI_FindUser(username
))
406 return NERR_UserNotFound
;
408 if (bufptr
) *bufptr
= NULL
;
409 if (entriesread
) *entriesread
= 0;
410 if (totalentries
) *totalentries
= 0;
415 /************************************************************
416 * NetUserEnum (NETAPI32.@)
418 NET_API_STATUS WINAPI
419 NetUserEnum(LPCWSTR servername
, DWORD level
, DWORD filter
, LPBYTE
* bufptr
,
420 DWORD prefmaxlen
, LPDWORD entriesread
, LPDWORD totalentries
,
421 LPDWORD resume_handle
)
423 FIXME("(%s,%d, 0x%d,%p,%d,%p,%p,%p) stub!\n", debugstr_w(servername
), level
,
424 filter
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resume_handle
);
426 return ERROR_ACCESS_DENIED
;
429 /************************************************************
430 * ACCESS_QueryAdminDisplayInformation
432 * Creates a buffer with information for the Admin User
434 static void ACCESS_QueryAdminDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
436 static const WCHAR sAdminUserName
[] = {
437 'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
439 /* sizes of the field buffers in WCHARS */
440 int name_sz
, comment_sz
, full_name_sz
;
441 PNET_DISPLAY_USER usr
;
444 name_sz
= lstrlenW(sAdminUserName
);
448 *pdwSize
= sizeof(NET_DISPLAY_USER
);
449 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
450 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
453 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
454 usr
->usri1_comment
= (LPWSTR
) (
455 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
456 usr
->usri1_full_name
= (LPWSTR
) (
457 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
460 lstrcpyW(usr
->usri1_name
, sAdminUserName
);
461 usr
->usri1_comment
[0] = 0;
462 usr
->usri1_flags
= UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
463 usr
->usri1_full_name
[0] = 0;
464 usr
->usri1_user_id
= 500;
465 usr
->usri1_next_index
= 0;
468 /************************************************************
469 * ACCESS_QueryGuestDisplayInformation
471 * Creates a buffer with information for the Guest User
473 static void ACCESS_QueryGuestDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
475 static const WCHAR sGuestUserName
[] = {
476 'G','u','e','s','t',0 };
478 /* sizes of the field buffers in WCHARS */
479 int name_sz
, comment_sz
, full_name_sz
;
480 PNET_DISPLAY_USER usr
;
483 name_sz
= lstrlenW(sGuestUserName
);
487 *pdwSize
= sizeof(NET_DISPLAY_USER
);
488 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
489 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
492 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
493 usr
->usri1_comment
= (LPWSTR
) (
494 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
495 usr
->usri1_full_name
= (LPWSTR
) (
496 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
499 lstrcpyW(usr
->usri1_name
, sGuestUserName
);
500 usr
->usri1_comment
[0] = 0;
501 usr
->usri1_flags
= UF_ACCOUNTDISABLE
| UF_SCRIPT
| UF_NORMAL_ACCOUNT
|
502 UF_DONT_EXPIRE_PASSWD
;
503 usr
->usri1_full_name
[0] = 0;
504 usr
->usri1_user_id
= 500;
505 usr
->usri1_next_index
= 0;
508 /************************************************************
509 * Copies NET_DISPLAY_USER record.
511 static void ACCESS_CopyDisplayUser(const NET_DISPLAY_USER
*dest
, LPWSTR
*dest_buf
,
512 PNET_DISPLAY_USER src
)
514 LPWSTR str
= *dest_buf
;
516 src
->usri1_name
= str
;
517 lstrcpyW(src
->usri1_name
, dest
->usri1_name
);
519 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
521 src
->usri1_comment
= str
;
522 lstrcpyW(src
->usri1_comment
, dest
->usri1_comment
);
524 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
526 src
->usri1_flags
= dest
->usri1_flags
;
528 src
->usri1_full_name
= str
;
529 lstrcpyW(src
->usri1_full_name
, dest
->usri1_full_name
);
531 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
533 src
->usri1_user_id
= dest
->usri1_user_id
;
534 src
->usri1_next_index
= dest
->usri1_next_index
;
538 /************************************************************
539 * NetQueryDisplayInformation (NETAPI32.@)
541 * The buffer structure:
542 * - array of fixed size record of the level type
543 * - strings, referenced by the record of the level type
545 NET_API_STATUS WINAPI
546 NetQueryDisplayInformation(
547 LPCWSTR ServerName
, DWORD Level
, DWORD Index
, DWORD EntriesRequested
,
548 DWORD PreferredMaximumLength
, LPDWORD ReturnedEntryCount
,
551 TRACE("(%s, %d, %d, %d, %d, %p, %p)\n", debugstr_w(ServerName
),
552 Level
, Index
, EntriesRequested
, PreferredMaximumLength
,
553 ReturnedEntryCount
, SortedBuffer
);
555 if(!NETAPI_IsLocalComputer(ServerName
))
557 FIXME("Only implemented on local computer, but requested for "
558 "remote server %s\n", debugstr_w(ServerName
));
559 return ERROR_ACCESS_DENIED
;
567 PNET_DISPLAY_USER inf
;
568 /* current available strings buffer */
570 PNET_DISPLAY_USER admin
, guest
;
571 DWORD admin_size
, guest_size
;
575 /* sizes of the field buffers in WCHARS */
576 int name_sz
, comment_sz
, full_name_sz
;
578 /* number of the records, returned in SortedBuffer
579 3 - for current user, Administrator and Guest users
583 FIXME("Level %d partially implemented\n", Level
);
584 *ReturnedEntryCount
= records
;
590 NetApiBufferAllocate(dwSize
, (LPVOID
*) &name
);
591 if (!GetUserNameW(name
, &dwSize
))
593 NetApiBufferFree(name
);
594 return ERROR_ACCESS_DENIED
;
597 ACCESS_QueryAdminDisplayInformation(&admin
, &admin_size
);
598 ACCESS_QueryGuestDisplayInformation(&guest
, &guest_size
);
601 dwSize
= sizeof(NET_DISPLAY_USER
) * records
;
602 dwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
604 NetApiBufferAllocate(dwSize
+
605 admin_size
- sizeof(NET_DISPLAY_USER
) +
606 guest_size
- sizeof(NET_DISPLAY_USER
),
607 (LPVOID
*) SortedBuffer
);
608 inf
= (PNET_DISPLAY_USER
) *SortedBuffer
;
609 str
= (LPWSTR
) ((PBYTE
) inf
+ sizeof(NET_DISPLAY_USER
) * records
);
610 inf
->usri1_name
= str
;
612 ((PBYTE
) str
) + name_sz
* sizeof(WCHAR
));
613 inf
->usri1_comment
= str
;
615 ((PBYTE
) str
) + comment_sz
* sizeof(WCHAR
));
616 inf
->usri1_full_name
= str
;
618 ((PBYTE
) str
) + full_name_sz
* sizeof(WCHAR
));
621 lstrcpyW(inf
->usri1_name
, name
);
622 NetApiBufferFree(name
);
623 inf
->usri1_comment
[0] = 0;
625 UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
626 inf
->usri1_full_name
[0] = 0;
627 inf
->usri1_user_id
= 0;
628 inf
->usri1_next_index
= 0;
631 ACCESS_CopyDisplayUser(admin
, &str
, inf
);
632 NetApiBufferFree(admin
);
635 ACCESS_CopyDisplayUser(guest
, &str
, inf
);
636 NetApiBufferFree(guest
);
643 FIXME("Level %d is not implemented\n", Level
);
648 TRACE("Invalid level %d is specified\n", Level
);
649 return ERROR_INVALID_LEVEL
;
654 /************************************************************
655 * NetGetDCName (NETAPI32.@)
657 * Return the name of the primary domain controller (PDC)
660 NET_API_STATUS WINAPI
661 NetGetDCName(LPCWSTR servername
, LPCWSTR domainname
, LPBYTE
*bufptr
)
663 FIXME("(%s, %s, %p) stub!\n", debugstr_w(servername
),
664 debugstr_w(domainname
), bufptr
);
665 return NERR_DCNotFound
; /* say we can't find a domain controller */
669 /******************************************************************************
670 * NetUserModalsGet (NETAPI32.@)
672 * Retrieves global information for all users and global groups in the security
676 * szServer [I] Specifies the DNS or the NetBIOS name of the remote server
677 * on which the function is to execute.
678 * level [I] Information level of the data.
679 * 0 Return global passwords parameters. bufptr points to a
680 * USER_MODALS_INFO_0 struct.
681 * 1 Return logon server and domain controller information. bufptr
682 * points to a USER_MODALS_INFO_1 struct.
683 * 2 Return domain name and identifier. bufptr points to a
684 * USER_MODALS_INFO_2 struct.
685 * 3 Return lockout information. bufptr points to a USER_MODALS_INFO_3
687 * pbuffer [I] Buffer that receives the data.
690 * Success: NERR_Success.
692 * ERROR_ACCESS_DENIED - the user does not have access to the info.
693 * NERR_InvalidComputer - computer name is invalid.
695 NET_API_STATUS WINAPI
NetUserModalsGet(
696 LPCWSTR szServer
, DWORD level
, LPBYTE
*pbuffer
)
698 TRACE("(%s %d %p)\n", debugstr_w(szServer
), level
, pbuffer
);
703 /* return global passwords parameters */
704 FIXME("level 0 not implemented!\n");
706 return NERR_InternalError
;
708 /* return logon server and domain controller info */
709 FIXME("level 1 not implemented!\n");
711 return NERR_InternalError
;
714 /* return domain name and identifier */
715 PUSER_MODALS_INFO_2 umi
;
716 LSA_HANDLE policyHandle
;
717 LSA_OBJECT_ATTRIBUTES objectAttributes
;
718 PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo
;
720 PSID domainIdentifier
= NULL
;
723 ZeroMemory(&objectAttributes
, sizeof(objectAttributes
));
724 objectAttributes
.Length
= sizeof(objectAttributes
);
726 ntStatus
= LsaOpenPolicy(NULL
, &objectAttributes
,
727 POLICY_VIEW_LOCAL_INFORMATION
,
729 if (ntStatus
!= STATUS_SUCCESS
)
731 WARN("LsaOpenPolicy failed with NT status %x\n",
732 LsaNtStatusToWinError(ntStatus
));
736 ntStatus
= LsaQueryInformationPolicy(policyHandle
,
737 PolicyAccountDomainInformation
,
738 (PVOID
*)&domainInfo
);
739 if (ntStatus
!= STATUS_SUCCESS
)
741 WARN("LsaQueryInformationPolicy failed with NT status %x\n",
742 LsaNtStatusToWinError(ntStatus
));
743 LsaClose(policyHandle
);
747 domainIdentifier
= domainInfo
->DomainSid
;
748 domainNameLen
= lstrlenW(domainInfo
->DomainName
.Buffer
) + 1;
749 LsaClose(policyHandle
);
751 ntStatus
= NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2
) +
752 GetLengthSid(domainIdentifier
) +
753 domainNameLen
* sizeof(WCHAR
),
756 if (ntStatus
!= NERR_Success
)
758 WARN("NetApiBufferAllocate() failed\n");
759 LsaFreeMemory(domainInfo
);
763 umi
= (USER_MODALS_INFO_2
*) *pbuffer
;
764 umi
->usrmod2_domain_id
= (PSID
)(*pbuffer
+
765 sizeof(USER_MODALS_INFO_2
));
766 umi
->usrmod2_domain_name
= (LPWSTR
)(*pbuffer
+
767 sizeof(USER_MODALS_INFO_2
) + GetLengthSid(domainIdentifier
));
769 lstrcpynW(umi
->usrmod2_domain_name
,
770 domainInfo
->DomainName
.Buffer
,
772 CopySid(GetLengthSid(domainIdentifier
), umi
->usrmod2_domain_id
,
775 LsaFreeMemory(domainInfo
);
780 /* return lockout information */
781 FIXME("level 3 not implemented!\n");
783 return NERR_InternalError
;
785 TRACE("Invalid level %d is specified\n", level
);
787 return ERROR_INVALID_LEVEL
;
793 /******************************************************************************
794 * NetUserChangePassword (NETAPI32.@)
796 * domainname [I] Optional. Domain on which the user resides or the logon
797 * domain of the current user if NULL.
798 * username [I] Optional. Username to change the password for or the name
799 * of the current user if NULL.
800 * oldpassword [I] The user's current password.
801 * newpassword [I] The password that the user will be changed to using.
804 * Success: NERR_Success.
805 * Failure: NERR_* failure code or win error code.
808 NET_API_STATUS WINAPI
NetUserChangePassword(LPCWSTR domainname
, LPCWSTR username
,
809 LPCWSTR oldpassword
, LPCWSTR newpassword
)
811 struct sam_user
*user
;
813 TRACE("(%s, %s, ..., ...)\n", debugstr_w(domainname
), debugstr_w(username
));
816 FIXME("Ignoring domainname %s.\n", debugstr_w(domainname
));
818 if((user
= NETAPI_FindUser(username
)) == NULL
)
819 return NERR_UserNotFound
;
821 if(lstrcmpW(user
->user_password
, oldpassword
) != 0)
822 return ERROR_INVALID_PASSWORD
;
824 if(lstrlenW(newpassword
) > PWLEN
)
825 return ERROR_PASSWORD_RESTRICTION
;
827 lstrcpyW(user
->user_password
, newpassword
);
832 NET_API_STATUS WINAPI
NetUseAdd(LMSTR servername
, DWORD level
, LPBYTE bufptr
, LPDWORD parm_err
)
834 FIXME("%s %d %p %p stub\n", debugstr_w(servername
), level
, bufptr
, parm_err
);