[NETAPI32]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 4 Jun 2017 14:34:27 +0000 (14:34 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 4 Jun 2017 14:34:27 +0000 (14:34 +0000)
- Implement NetSessionDel, NetSessionEnum and NetSessionGetInfo. These functions call their counterparts in the server service.

svn path=/trunk/; revision=74910

reactos/dll/win32/netapi32/netapi32.spec
reactos/dll/win32/netapi32/share.c
reactos/dll/win32/netapi32/srvsvc.c

index 8373cbc..5697831 100644 (file)
 @ stub NetServiceEnum
 @ stub NetServiceGetInfo
 @ stub NetServiceInstall
-@ stub NetSessionDel
+@ stdcall NetSessionDel(wstr wstr wstr)
 @ stdcall NetSessionEnum(wstr wstr wstr long ptr long ptr ptr ptr)
-@ stub NetSessionGetInfo
+@ stdcall NetSessionGetInfo(wstr wstr wstr long ptr)
 @ stub NetSetPrimaryComputerName
 @ stdcall NetShareAdd(wstr long ptr ptr)
 @ stdcall NetShareCheck(wstr wstr ptr)
index eb33da7..52463e3 100644 (file)
 
 WINE_DEFAULT_DEBUG_CHANNEL(share);
 
-/************************************************************
- * NetSessionEnum  (NETAPI32.@)
- *
- * PARAMS
- *   servername    [I]   Pointer to a string with the name of the server
- *   UncClientName [I]   Pointer to a string with the name of the session
- *   username      [I]   Pointer to a string with the name of the user
- *   level         [I]   Data information level
- *   bufptr        [O]   Buffer to the data
- *   prefmaxlen    [I]   Preferred maximum length of the data
- *   entriesread   [O]   Pointer to the number of entries enumerated
- *   totalentries  [O]   Pointer to the possible number of entries
- *   resume_handle [I/O] Pointer to a handle for subsequent searches
- *
- * RETURNS
- *   If successful, the function returns NERR_Success
- *   On failure it returns:
- *     ERROR_ACCESS_DENIED         User has no access to the requested information
- *     ERROR_INVALID_LEVEL         Value of 'level' is not correct
- *     ERROR_INVALID_PARAMETER     Wrong parameter
- *     ERROR_MORE_DATA             Need a larger buffer
- *     ERROR_NOT_ENOUGH_MEMORY     Not enough memory
- *     NERR_ClientNameNotFound     A session does not exist on a given computer
- *     NERR_InvalidComputer        Invalid computer name
- *     NERR_UserNotFound           User name could not be found.
- */
-NET_API_STATUS WINAPI NetSessionEnum(LMSTR servername, LMSTR UncClientName,
-    LMSTR username, DWORD level, LPBYTE* bufptr, DWORD prefmaxlen, LPDWORD entriesread,
-    LPDWORD totalentries, LPDWORD resume_handle)
-{
-    FIXME("Stub (%s %s %s %d %p %d %p %p %p)\n", debugstr_w(servername),
-        debugstr_w(UncClientName), debugstr_w(username),
-        level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
-
-    return NERR_Success;
-}
-
 /************************************************************
  *                NetFileEnum  (NETAPI32.@)
  */
index 563a5f4..2b0d179 100644 (file)
@@ -98,6 +98,247 @@ NetRemoteTOD(
 }
 
 
+NET_API_STATUS
+WINAPI
+NetSessionDel(
+    _In_ LMSTR servername,
+    _In_ LMSTR UncClientName,
+    _In_ LMSTR username)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetSessionDel(%s %s %s)\n",
+          debugstr_w(servername), debugstr_w(UncClientName), debugstr_w(username));
+
+    RpcTryExcept
+    {
+        status = NetrSessionDel(servername,
+                                UncClientName,
+                                username);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetSessionEnum(
+    _In_ LMSTR servername,
+    _In_ LMSTR UncClientName,
+    _In_ LMSTR username,
+    _In_ DWORD level,
+    _Out_ LPBYTE *bufptr,
+    _In_ DWORD prefmaxlen,
+    _Out_ LPDWORD entriesread,
+    _Out_ LPDWORD totalentries,
+    _Inout_ LPDWORD resume_handle)
+{
+    SESSION_ENUM_STRUCT EnumStruct;
+    SESSION_INFO_0_CONTAINER Level0Container = {0, NULL};
+    SESSION_INFO_1_CONTAINER Level1Container = {0, NULL};
+    SESSION_INFO_2_CONTAINER Level2Container = {0, NULL};
+    SESSION_INFO_10_CONTAINER Level10Container = {0, NULL};
+    SESSION_INFO_502_CONTAINER Level502Container = {0, NULL};
+    NET_API_STATUS status;
+
+    FIXME("NetSessionEnum(%s %s %s %lu %p %lu %p %p %p)\n",
+          debugstr_w(servername), debugstr_w(UncClientName), debugstr_w(username),
+          level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
+
+    if (level > 2 && level != 10 && level != 502)
+        return ERROR_INVALID_LEVEL;
+
+    if (UncClientName == NULL || username == NULL)
+        return ERROR_INVALID_PARAMETER;
+
+    *bufptr = NULL;
+    *entriesread = 0;
+
+    EnumStruct.Level = level;
+    switch (level)
+    {
+        case 0:
+            EnumStruct.SessionInfo.Level0 = &Level0Container;
+            break;
+
+        case 1:
+            EnumStruct.SessionInfo.Level1 = &Level1Container;
+            break;
+
+        case 2:
+            EnumStruct.SessionInfo.Level2 = &Level2Container;
+            break;
+
+        case 10:
+            EnumStruct.SessionInfo.Level10 = &Level10Container;
+            break;
+
+        case 502:
+            EnumStruct.SessionInfo.Level502 = &Level502Container;
+            break;
+    }
+
+    RpcTryExcept
+    {
+        status = NetrSessionEnum(servername,
+                                 UncClientName,
+                                 username,
+                                 &EnumStruct,
+                                 prefmaxlen,
+                                 totalentries,
+                                 resume_handle);
+
+        switch (level)
+        {
+            case 0:
+                if (EnumStruct.SessionInfo.Level0->Buffer != NULL)
+                {
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level0->Buffer;
+                    *entriesread = EnumStruct.SessionInfo.Level0->EntriesRead;
+                }
+                break;
+
+            case 1:
+                if (EnumStruct.SessionInfo.Level1->Buffer != NULL)
+                {
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level1->Buffer;
+                    *entriesread = EnumStruct.SessionInfo.Level1->EntriesRead;
+                }
+                break;
+
+            case 2:
+                if (EnumStruct.SessionInfo.Level2->Buffer != NULL)
+                {
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level2->Buffer;
+                    *entriesread = EnumStruct.SessionInfo.Level2->EntriesRead;
+                }
+                break;
+
+            case 10:
+                if (EnumStruct.SessionInfo.Level10->Buffer != NULL)
+                {
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level10->Buffer;
+                    *entriesread = EnumStruct.SessionInfo.Level10->EntriesRead;
+                }
+                break;
+
+            case 502:
+                if (EnumStruct.SessionInfo.Level502->Buffer != NULL)
+                {
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level502->Buffer;
+                    *entriesread = EnumStruct.SessionInfo.Level502->EntriesRead;
+                }
+                break;
+        }
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetSessionGetInfo(
+    _In_ LMSTR servername,
+    _In_ LMSTR UncClientName,
+    _In_ LMSTR username,
+    _In_ DWORD level,
+    _Out_ LPBYTE *bufptr)
+{
+    SESSION_ENUM_STRUCT EnumStruct;
+    SESSION_INFO_0_CONTAINER Level0Container = {0, NULL};
+    SESSION_INFO_1_CONTAINER Level1Container = {0, NULL};
+    SESSION_INFO_2_CONTAINER Level2Container = {0, NULL};
+    SESSION_INFO_10_CONTAINER Level10Container = {0, NULL};
+    DWORD dwTotalEntries;
+    NET_API_STATUS status;
+
+    FIXME("NetSessionGetInfo(%s %s %s %lu %p)\n",
+          debugstr_w(servername), debugstr_w(UncClientName),
+          debugstr_w(username), level, bufptr);
+
+    if (level > 2 && level != 10)
+        return ERROR_INVALID_LEVEL;
+
+    if (UncClientName == NULL || username == NULL)
+        return ERROR_INVALID_PARAMETER;
+
+    *bufptr = NULL;
+
+    EnumStruct.Level = level;
+    switch (level)
+    {
+        case 0:
+            EnumStruct.SessionInfo.Level0 = &Level0Container;
+            break;
+
+        case 1:
+            EnumStruct.SessionInfo.Level1 = &Level1Container;
+            break;
+
+        case 2:
+            EnumStruct.SessionInfo.Level2 = &Level2Container;
+            break;
+
+        case 10:
+            EnumStruct.SessionInfo.Level10 = &Level10Container;
+            break;
+    }
+
+    RpcTryExcept
+    {
+        status = NetrSessionEnum(servername,
+                                 UncClientName,
+                                 username,
+                                 &EnumStruct,
+                                 MAX_PREFERRED_LENGTH, //(DWORD)-1,
+                                 &dwTotalEntries,
+                                 NULL);
+
+        switch (level)
+        {
+            case 0:
+                if (EnumStruct.SessionInfo.Level0->Buffer != NULL)
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level0->Buffer;
+                break;
+
+            case 1:
+                if (EnumStruct.SessionInfo.Level1->Buffer != NULL)
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level1->Buffer;
+                break;
+
+            case 2:
+                if (EnumStruct.SessionInfo.Level2->Buffer != NULL)
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level2->Buffer;
+                break;
+
+            case 10:
+                if (EnumStruct.SessionInfo.Level10->Buffer != NULL)
+                    *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level10->Buffer;
+                break;
+        }
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
 NET_API_STATUS
 WINAPI
 NetShareAdd(
@@ -156,7 +397,6 @@ NetShareCheck(
     RpcEndExcept;
 
     return status;
-
 }