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
);
188 /************************************************************
189 * NetUserDel (NETAPI32.@)
191 NET_API_STATUS WINAPI
NetUserDel(LPCWSTR servername
, LPCWSTR username
)
193 NET_API_STATUS status
;
194 struct sam_user
*user
;
196 TRACE("(%s, %s)\n", debugstr_w(servername
), debugstr_w(username
));
198 if((status
= NETAPI_ValidateServername(servername
))!= NERR_Success
)
201 if ((user
= NETAPI_FindUser(username
)) == NULL
)
202 return NERR_UserNotFound
;
204 list_remove(&user
->entry
);
206 HeapFree(GetProcessHeap(), 0, user
->home_dir
);
207 HeapFree(GetProcessHeap(), 0, user
->user_comment
);
208 HeapFree(GetProcessHeap(), 0, user
->user_logon_script_path
);
209 HeapFree(GetProcessHeap(), 0, user
);
214 /************************************************************
215 * NetUserGetInfo (NETAPI32.@)
217 NET_API_STATUS WINAPI
218 NetUserGetInfo(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
221 NET_API_STATUS status
;
222 TRACE("(%s, %s, %d, %p)\n", debugstr_w(servername
), debugstr_w(username
),
224 status
= NETAPI_ValidateServername(servername
);
225 if (status
!= NERR_Success
)
228 if(!NETAPI_IsLocalComputer(servername
))
230 FIXME("Only implemented for local computer, but remote server"
231 "%s was requested.\n", debugstr_w(servername
));
232 return NERR_InvalidComputer
;
235 if(!NETAPI_FindUser(username
))
237 TRACE("User %s is unknown.\n", debugstr_w(username
));
238 return NERR_UserNotFound
;
248 name_sz
= lstrlenW(username
) + 1;
251 NetApiBufferAllocate(sizeof(USER_INFO_0
) + name_sz
* sizeof(WCHAR
),
254 ui
= (PUSER_INFO_0
) *bufptr
;
255 ui
->usri0_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_0
));
258 lstrcpyW(ui
->usri0_name
, username
);
266 NET_API_STATUS status
;
267 /* sizes of the field buffers in WCHARS */
268 int name_sz
, comment_sz
, usr_comment_sz
, full_name_sz
;
275 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
276 if (status
!= NERR_Success
)
278 NetApiBufferFree(ui0
);
281 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
284 NetApiBufferAllocate(sizeof(USER_INFO_10
) +
285 (name_sz
+ comment_sz
+ usr_comment_sz
+
286 full_name_sz
) * sizeof(WCHAR
),
288 ui
= (PUSER_INFO_10
) *bufptr
;
289 ui
->usri10_name
= (LPWSTR
) (*bufptr
+ sizeof(USER_INFO_10
));
290 ui
->usri10_comment
= (LPWSTR
) (
291 ((PBYTE
) ui
->usri10_name
) + name_sz
* sizeof(WCHAR
));
292 ui
->usri10_usr_comment
= (LPWSTR
) (
293 ((PBYTE
) ui
->usri10_comment
) + comment_sz
* sizeof(WCHAR
));
294 ui
->usri10_full_name
= (LPWSTR
) (
295 ((PBYTE
) ui
->usri10_usr_comment
) + usr_comment_sz
* sizeof(WCHAR
));
298 lstrcpyW(ui
->usri10_name
, ui0
->usri0_name
);
299 NetApiBufferFree(ui0
);
300 ui
->usri10_comment
[0] = 0;
301 ui
->usri10_usr_comment
[0] = 0;
302 ui
->usri10_full_name
[0] = 0;
308 static const WCHAR homedirW
[] = {'H','O','M','E',0};
311 NET_API_STATUS status
;
312 /* sizes of the field buffers in WCHARS */
313 int name_sz
, password_sz
, home_dir_sz
, comment_sz
, script_path_sz
;
315 password_sz
= 1; /* not filled out for security reasons for NetUserGetInfo*/
320 status
= NetUserGetInfo(servername
, username
, 0, (LPBYTE
*) &ui0
);
321 if (status
!= NERR_Success
)
323 NetApiBufferFree(ui0
);
326 name_sz
= lstrlenW(ui0
->usri0_name
) + 1;
327 home_dir_sz
= GetEnvironmentVariableW(homedirW
, NULL
,0);
329 NetApiBufferAllocate(sizeof(USER_INFO_1
) +
330 (name_sz
+ password_sz
+ home_dir_sz
+
331 comment_sz
+ script_path_sz
) * sizeof(WCHAR
),
334 ui
= (PUSER_INFO_1
) *bufptr
;
335 ui
->usri1_name
= (LPWSTR
) (ui
+ 1);
336 ui
->usri1_password
= ui
->usri1_name
+ name_sz
;
337 ui
->usri1_home_dir
= ui
->usri1_password
+ password_sz
;
338 ui
->usri1_comment
= ui
->usri1_home_dir
+ home_dir_sz
;
339 ui
->usri1_script_path
= ui
->usri1_comment
+ comment_sz
;
341 lstrcpyW(ui
->usri1_name
, ui0
->usri0_name
);
342 NetApiBufferFree(ui0
);
343 ui
->usri1_password
[0] = 0;
344 ui
->usri1_password_age
= 0;
346 GetEnvironmentVariableW(homedirW
, ui
->usri1_home_dir
,home_dir_sz
);
347 ui
->usri1_comment
[0] = 0;
349 ui
->usri1_script_path
[0] = 0;
379 FIXME("Level %d is not implemented\n", level
);
380 return NERR_InternalError
;
383 TRACE("Invalid level %d is specified\n", level
);
384 return ERROR_INVALID_LEVEL
;
389 /************************************************************
390 * NetUserGetLocalGroups (NETAPI32.@)
392 NET_API_STATUS WINAPI
393 NetUserGetLocalGroups(LPCWSTR servername
, LPCWSTR username
, DWORD level
,
394 DWORD flags
, LPBYTE
* bufptr
, DWORD prefmaxlen
,
395 LPDWORD entriesread
, LPDWORD totalentries
)
397 NET_API_STATUS status
;
399 FIXME("(%s, %s, %d, %08x, %p %d, %p, %p) stub!\n",
400 debugstr_w(servername
), debugstr_w(username
), level
, flags
, bufptr
,
401 prefmaxlen
, entriesread
, totalentries
);
403 status
= NETAPI_ValidateServername(servername
);
404 if (status
!= NERR_Success
)
407 if (!NETAPI_FindUser(username
))
408 return NERR_UserNotFound
;
410 if (bufptr
) *bufptr
= NULL
;
411 if (entriesread
) *entriesread
= 0;
412 if (totalentries
) *totalentries
= 0;
417 /************************************************************
418 * NetUserEnum (NETAPI32.@)
420 NET_API_STATUS WINAPI
421 NetUserEnum(LPCWSTR servername
, DWORD level
, DWORD filter
, LPBYTE
* bufptr
,
422 DWORD prefmaxlen
, LPDWORD entriesread
, LPDWORD totalentries
,
423 LPDWORD resume_handle
)
425 FIXME("(%s,%d, 0x%d,%p,%d,%p,%p,%p) stub!\n", debugstr_w(servername
), level
,
426 filter
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resume_handle
);
428 return ERROR_ACCESS_DENIED
;
431 /************************************************************
432 * ACCESS_QueryAdminDisplayInformation
434 * Creates a buffer with information for the Admin User
436 static void ACCESS_QueryAdminDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
438 static const WCHAR sAdminUserName
[] = {
439 'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
441 /* sizes of the field buffers in WCHARS */
442 int name_sz
, comment_sz
, full_name_sz
;
443 PNET_DISPLAY_USER usr
;
446 name_sz
= lstrlenW(sAdminUserName
);
450 *pdwSize
= sizeof(NET_DISPLAY_USER
);
451 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
452 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
455 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
456 usr
->usri1_comment
= (LPWSTR
) (
457 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
458 usr
->usri1_full_name
= (LPWSTR
) (
459 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
462 lstrcpyW(usr
->usri1_name
, sAdminUserName
);
463 usr
->usri1_comment
[0] = 0;
464 usr
->usri1_flags
= UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
465 usr
->usri1_full_name
[0] = 0;
466 usr
->usri1_user_id
= 500;
467 usr
->usri1_next_index
= 0;
470 /************************************************************
471 * ACCESS_QueryGuestDisplayInformation
473 * Creates a buffer with information for the Guest User
475 static void ACCESS_QueryGuestDisplayInformation(PNET_DISPLAY_USER
*buf
, PDWORD pdwSize
)
477 static const WCHAR sGuestUserName
[] = {
478 'G','u','e','s','t',0 };
480 /* sizes of the field buffers in WCHARS */
481 int name_sz
, comment_sz
, full_name_sz
;
482 PNET_DISPLAY_USER usr
;
485 name_sz
= lstrlenW(sGuestUserName
);
489 *pdwSize
= sizeof(NET_DISPLAY_USER
);
490 *pdwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
491 NetApiBufferAllocate(*pdwSize
, (LPVOID
*) buf
);
494 usr
->usri1_name
= (LPWSTR
) ((PBYTE
) usr
+ sizeof(NET_DISPLAY_USER
));
495 usr
->usri1_comment
= (LPWSTR
) (
496 ((PBYTE
) usr
->usri1_name
) + name_sz
* sizeof(WCHAR
));
497 usr
->usri1_full_name
= (LPWSTR
) (
498 ((PBYTE
) usr
->usri1_comment
) + comment_sz
* sizeof(WCHAR
));
501 lstrcpyW(usr
->usri1_name
, sGuestUserName
);
502 usr
->usri1_comment
[0] = 0;
503 usr
->usri1_flags
= UF_ACCOUNTDISABLE
| UF_SCRIPT
| UF_NORMAL_ACCOUNT
|
504 UF_DONT_EXPIRE_PASSWD
;
505 usr
->usri1_full_name
[0] = 0;
506 usr
->usri1_user_id
= 500;
507 usr
->usri1_next_index
= 0;
510 /************************************************************
511 * Copies NET_DISPLAY_USER record.
513 static void ACCESS_CopyDisplayUser(const NET_DISPLAY_USER
*dest
, LPWSTR
*dest_buf
,
514 PNET_DISPLAY_USER src
)
516 LPWSTR str
= *dest_buf
;
518 src
->usri1_name
= str
;
519 lstrcpyW(src
->usri1_name
, dest
->usri1_name
);
521 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
523 src
->usri1_comment
= str
;
524 lstrcpyW(src
->usri1_comment
, dest
->usri1_comment
);
526 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
528 src
->usri1_flags
= dest
->usri1_flags
;
530 src
->usri1_full_name
= str
;
531 lstrcpyW(src
->usri1_full_name
, dest
->usri1_full_name
);
533 ((PBYTE
) str
) + (lstrlenW(str
) + 1) * sizeof(WCHAR
));
535 src
->usri1_user_id
= dest
->usri1_user_id
;
536 src
->usri1_next_index
= dest
->usri1_next_index
;
540 /************************************************************
541 * NetQueryDisplayInformation (NETAPI32.@)
543 * The buffer structure:
544 * - array of fixed size record of the level type
545 * - strings, referenced by the record of the level type
547 NET_API_STATUS WINAPI
548 NetQueryDisplayInformation(
549 LPCWSTR ServerName
, DWORD Level
, DWORD Index
, DWORD EntriesRequested
,
550 DWORD PreferredMaximumLength
, LPDWORD ReturnedEntryCount
,
553 TRACE("(%s, %d, %d, %d, %d, %p, %p)\n", debugstr_w(ServerName
),
554 Level
, Index
, EntriesRequested
, PreferredMaximumLength
,
555 ReturnedEntryCount
, SortedBuffer
);
557 if(!NETAPI_IsLocalComputer(ServerName
))
559 FIXME("Only implemented on local computer, but requested for "
560 "remote server %s\n", debugstr_w(ServerName
));
561 return ERROR_ACCESS_DENIED
;
569 PNET_DISPLAY_USER inf
;
570 /* current available strings buffer */
572 PNET_DISPLAY_USER admin
, guest
;
573 DWORD admin_size
, guest_size
;
577 /* sizes of the field buffers in WCHARS */
578 int name_sz
, comment_sz
, full_name_sz
;
580 /* number of the records, returned in SortedBuffer
581 3 - for current user, Administrator and Guest users
585 FIXME("Level %d partially implemented\n", Level
);
586 *ReturnedEntryCount
= records
;
592 NetApiBufferAllocate(dwSize
, (LPVOID
*) &name
);
593 if (!GetUserNameW(name
, &dwSize
))
595 NetApiBufferFree(name
);
596 return ERROR_ACCESS_DENIED
;
599 ACCESS_QueryAdminDisplayInformation(&admin
, &admin_size
);
600 ACCESS_QueryGuestDisplayInformation(&guest
, &guest_size
);
603 dwSize
= sizeof(NET_DISPLAY_USER
) * records
;
604 dwSize
+= (name_sz
+ comment_sz
+ full_name_sz
) * sizeof(WCHAR
);
606 NetApiBufferAllocate(dwSize
+
607 admin_size
- sizeof(NET_DISPLAY_USER
) +
608 guest_size
- sizeof(NET_DISPLAY_USER
),
609 (LPVOID
*) SortedBuffer
);
610 inf
= (PNET_DISPLAY_USER
) *SortedBuffer
;
611 str
= (LPWSTR
) ((PBYTE
) inf
+ sizeof(NET_DISPLAY_USER
) * records
);
612 inf
->usri1_name
= str
;
614 ((PBYTE
) str
) + name_sz
* sizeof(WCHAR
));
615 inf
->usri1_comment
= str
;
617 ((PBYTE
) str
) + comment_sz
* sizeof(WCHAR
));
618 inf
->usri1_full_name
= str
;
620 ((PBYTE
) str
) + full_name_sz
* sizeof(WCHAR
));
623 lstrcpyW(inf
->usri1_name
, name
);
624 NetApiBufferFree(name
);
625 inf
->usri1_comment
[0] = 0;
627 UF_SCRIPT
| UF_NORMAL_ACCOUNT
| UF_DONT_EXPIRE_PASSWD
;
628 inf
->usri1_full_name
[0] = 0;
629 inf
->usri1_user_id
= 0;
630 inf
->usri1_next_index
= 0;
633 ACCESS_CopyDisplayUser(admin
, &str
, inf
);
634 NetApiBufferFree(admin
);
637 ACCESS_CopyDisplayUser(guest
, &str
, inf
);
638 NetApiBufferFree(guest
);
645 FIXME("Level %d is not implemented\n", Level
);
650 TRACE("Invalid level %d is specified\n", Level
);
651 return ERROR_INVALID_LEVEL
;
656 /************************************************************
657 * NetGetDCName (NETAPI32.@)
659 * Return the name of the primary domain controller (PDC)
662 NET_API_STATUS WINAPI
663 NetGetDCName(LPCWSTR servername
, LPCWSTR domainname
, LPBYTE
*bufptr
)
665 FIXME("(%s, %s, %p) stub!\n", debugstr_w(servername
),
666 debugstr_w(domainname
), bufptr
);
667 return NERR_DCNotFound
; /* say we can't find a domain controller */
671 /******************************************************************************
672 * NetUserModalsGet (NETAPI32.@)
674 * Retrieves global information for all users and global groups in the security
678 * szServer [I] Specifies the DNS or the NetBIOS name of the remote server
679 * on which the function is to execute.
680 * level [I] Information level of the data.
681 * 0 Return global passwords parameters. bufptr points to a
682 * USER_MODALS_INFO_0 struct.
683 * 1 Return logon server and domain controller information. bufptr
684 * points to a USER_MODALS_INFO_1 struct.
685 * 2 Return domain name and identifier. bufptr points to a
686 * USER_MODALS_INFO_2 struct.
687 * 3 Return lockout information. bufptr points to a USER_MODALS_INFO_3
689 * pbuffer [I] Buffer that receives the data.
692 * Success: NERR_Success.
694 * ERROR_ACCESS_DENIED - the user does not have access to the info.
695 * NERR_InvalidComputer - computer name is invalid.
697 NET_API_STATUS WINAPI
NetUserModalsGet(
698 LPCWSTR szServer
, DWORD level
, LPBYTE
*pbuffer
)
700 TRACE("(%s %d %p)\n", debugstr_w(szServer
), level
, pbuffer
);
705 /* return global passwords parameters */
706 FIXME("level 0 not implemented!\n");
708 return NERR_InternalError
;
710 /* return logon server and domain controller info */
711 FIXME("level 1 not implemented!\n");
713 return NERR_InternalError
;
716 /* return domain name and identifier */
717 PUSER_MODALS_INFO_2 umi
;
718 LSA_HANDLE policyHandle
;
719 LSA_OBJECT_ATTRIBUTES objectAttributes
;
720 PPOLICY_ACCOUNT_DOMAIN_INFO domainInfo
;
722 PSID domainIdentifier
= NULL
;
725 ZeroMemory(&objectAttributes
, sizeof(objectAttributes
));
726 objectAttributes
.Length
= sizeof(objectAttributes
);
728 ntStatus
= LsaOpenPolicy(NULL
, &objectAttributes
,
729 POLICY_VIEW_LOCAL_INFORMATION
,
731 if (ntStatus
!= STATUS_SUCCESS
)
733 WARN("LsaOpenPolicy failed with NT status %x\n",
734 LsaNtStatusToWinError(ntStatus
));
738 ntStatus
= LsaQueryInformationPolicy(policyHandle
,
739 PolicyAccountDomainInformation
,
740 (PVOID
*)&domainInfo
);
741 if (ntStatus
!= STATUS_SUCCESS
)
743 WARN("LsaQueryInformationPolicy failed with NT status %x\n",
744 LsaNtStatusToWinError(ntStatus
));
745 LsaClose(policyHandle
);
749 domainIdentifier
= domainInfo
->DomainSid
;
750 domainNameLen
= lstrlenW(domainInfo
->DomainName
.Buffer
) + 1;
751 LsaClose(policyHandle
);
753 ntStatus
= NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2
) +
754 GetLengthSid(domainIdentifier
) +
755 domainNameLen
* sizeof(WCHAR
),
758 if (ntStatus
!= NERR_Success
)
760 WARN("NetApiBufferAllocate() failed\n");
761 LsaFreeMemory(domainInfo
);
765 umi
= (USER_MODALS_INFO_2
*) *pbuffer
;
766 umi
->usrmod2_domain_id
= (PSID
)(*pbuffer
+
767 sizeof(USER_MODALS_INFO_2
));
768 umi
->usrmod2_domain_name
= (LPWSTR
)(*pbuffer
+
769 sizeof(USER_MODALS_INFO_2
) + GetLengthSid(domainIdentifier
));
771 lstrcpynW(umi
->usrmod2_domain_name
,
772 domainInfo
->DomainName
.Buffer
,
774 CopySid(GetLengthSid(domainIdentifier
), umi
->usrmod2_domain_id
,
777 LsaFreeMemory(domainInfo
);
782 /* return lockout information */
783 FIXME("level 3 not implemented!\n");
785 return NERR_InternalError
;
787 TRACE("Invalid level %d is specified\n", level
);
789 return ERROR_INVALID_LEVEL
;
795 /******************************************************************************
796 * NetUserChangePassword (NETAPI32.@)
798 * domainname [I] Optional. Domain on which the user resides or the logon
799 * domain of the current user if NULL.
800 * username [I] Optional. Username to change the password for or the name
801 * of the current user if NULL.
802 * oldpassword [I] The user's current password.
803 * newpassword [I] The password that the user will be changed to using.
806 * Success: NERR_Success.
807 * Failure: NERR_* failure code or win error code.
810 NET_API_STATUS WINAPI
NetUserChangePassword(LPCWSTR domainname
, LPCWSTR username
,
811 LPCWSTR oldpassword
, LPCWSTR newpassword
)
813 struct sam_user
*user
;
815 TRACE("(%s, %s, ..., ...)\n", debugstr_w(domainname
), debugstr_w(username
));
818 FIXME("Ignoring domainname %s.\n", debugstr_w(domainname
));
820 if((user
= NETAPI_FindUser(username
)) == NULL
)
821 return NERR_UserNotFound
;
823 if(lstrcmpW(user
->user_password
, oldpassword
) != 0)
824 return ERROR_INVALID_PASSWORD
;
826 if(lstrlenW(newpassword
) > PWLEN
)
827 return ERROR_PASSWORD_RESTRICTION
;
829 lstrcpyW(user
->user_password
, newpassword
);
834 NET_API_STATUS WINAPI
NetUseAdd(LMSTR servername
, DWORD level
, LPBYTE bufptr
, LPDWORD parm_err
)
836 FIXME("%s %d %p %p stub\n", debugstr_w(servername
), level
, bufptr
, parm_err
);