NetUserEnum

Stefan Leichter Stefan.Leichter at camLine.com
Sun Jan 29 03:10:18 CST 2006


Hello,

some things me think are not correct.

1. you fill the values into the memory pointed by data but how is data passed 
back to the caller of the function ?
2. the string you like to pass back for some fields of the USER_INFO_20 is 
ASCII but it must be UNICODE (change char -> WCHAR).
3. the above string  is not terminated (add ,0)

Note: For 2 and 3 you need to adjust the count of memcpy or better use 
lstrcpy[n]W.

By Stefan

Am Samstag, 28. Januar 2006 06:02 schrieb suppandi:
> Hi,
>
> I was trying to run notes7 and it was crashing because NetUserEnum() was
> not implemented. So i tried writing a simple implementation. Could anybody
> have a look at this, and tell me whats wrong. Now notes just crashes
> without any doc. unfortunately i amn't a windows programmer to write a
> simple program to make the call.
>
> NetUserEnum(LPCWSTR servername, DWORD level, DWORD filter, LPBYTE* bufptr,
>             DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries,
>             LPDWORD resume_handle)
> {
>   struct USER_INFO_20
>   {
>       LPWSTR usri20_name;
>       LPWSTR usri20_full_name;
>       LPWSTR usri20_comment;
>       DWORD  usri20_flags;
>       DWORD  usri20_user_id;
>   };
>
>   switch(level)
>   {
>      case 20:
>      {
>         struct USER_INFO_20 *data;
>         char user[]={'t','e','s','t'};
>         NetApiBufferAllocate(sizeof(struct USER_INFO_20),
>                              (LPVOID *) bufptr);
>         data = (struct USER_INFO_20 *)malloc(sizeof(struct USER_INFO_20));
>         data->usri20_name = (LPWSTR)malloc(20);
>         memcpy((void*)data->usri20_name,user,4);
>         data->usri20_full_name = (LPWSTR)malloc(20);
>         memcpy((void*)data->usri20_full_name,user,4);
>         data->usri20_comment = (LPWSTR)malloc(20);
>         memcpy((void*)data->usri20_comment,user,4);
>         data->usri20_flags = UF_NORMAL_ACCOUNT;
>         data->usri20_user_id = 1000;
>         *entriesread = *totalentries = 1;
>         return 0;
>      }
>      break;
>      default:
>        FIXME("(%s,%ld, 0x%ld,%p,%ld,%p,%p,%p) stub!\n",
> debugstr_w(servername), level,
>           filter, bufptr, prefmaxlen, entriesread, totalentries,
> resume_handle);
>
>        return ERROR_ACCESS_DENIED;
>      break;
>   }
> }



More information about the wine-devel mailing list