[NETAPI32]
authorEric Kohl <eric.kohl@reactos.org>
Mon, 16 Mar 2015 20:03:54 +0000 (20:03 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Mon, 16 Mar 2015 20:03:54 +0000 (20:03 +0000)
Implement NetUseAdd, NetUseDel, NetUseEnum and NetUseGetInfo.

svn path=/trunk/; revision=66743

reactos/dll/win32/netapi32/access.c
reactos/dll/win32/netapi32/netapi32.c
reactos/dll/win32/netapi32/netapi32.spec
reactos/dll/win32/netapi32/wksta_new.c

index 7ba2fa5..1f8262b 100644 (file)
@@ -260,10 +260,3 @@ NetGetDCName(LPCWSTR servername, LPCWSTR domainname, LPBYTE *bufptr)
                  debugstr_w(domainname), bufptr);
   return NERR_DCNotFound; /* say we can't find a domain controller */  
 }
-
-
-NET_API_STATUS WINAPI NetUseAdd(LMSTR servername, DWORD level, LPBYTE bufptr, LPDWORD parm_err)
-{
-    FIXME("%s %d %p %p stub\n", debugstr_w(servername), level, bufptr, parm_err);
-    return NERR_Success;
-}
index 5c0b947..ecc66e2 100644 (file)
@@ -202,14 +202,6 @@ NetpNtStatusToApiStatus(NTSTATUS Status)
     return ApiStatus;
 }
 
-NET_API_STATUS WINAPI NetUseEnum(LMSTR server, DWORD level, LPBYTE* bufptr, DWORD prefmaxsize,
-                          LPDWORD entriesread, LPDWORD totalentries, LPDWORD resumehandle)
-{
-    FIXME("stub (%p, %d, %p, %d, %p, %p, %p)\n", server, level, bufptr, prefmaxsize,
-           entriesread, totalentries, resumehandle);
-    return ERROR_NOT_SUPPORTED;
-}
-
 NET_API_STATUS WINAPI NetScheduleJobAdd(LPCWSTR server, LPBYTE bufptr, LPDWORD jobid)
 {
     FIXME("stub (%s, %p, %p)\n", debugstr_w(server), bufptr, jobid);
@@ -231,9 +223,3 @@ NET_API_STATUS WINAPI NetScheduleJobEnum(LPCWSTR server, LPBYTE* bufptr, DWORD p
     return NERR_Success;
 }
 
-NET_API_STATUS WINAPI NetUseGetInfo(LMSTR server, LMSTR name, DWORD level, LPBYTE *bufptr)
-{
-    FIXME("stub (%p, %p, %d, %p)\n", server, name, level, bufptr);
-    return ERROR_NOT_SUPPORTED;
-
-}
index 6ad4825..c7c8de3 100644 (file)
 @ stub NetUnjoinDomain
 @ stub NetUnregisterDomainNameChangeNotification
 @ stdcall NetUseAdd(wstr long ptr ptr)
-@ stub NetUseDel
+@ stdcall NetUseDel(wstr wstr long)
 @ stdcall NetUseEnum(wstr long ptr long ptr ptr ptr)
 @ stdcall NetUseGetInfo(ptr ptr long ptr)
 @ stdcall NetUserAdd(wstr long ptr ptr)
index 7ca7cdd..4b8240e 100644 (file)
@@ -147,7 +147,7 @@ NetGetJoinInformation(
 {
     NET_API_STATUS status;
 
-    TRACE("NetGetJoinInformation(%s %p %p)\n", wine_dbgstr_w(Server),
+    TRACE("NetGetJoinInformation(%s %p %p)\n", debugstr_w(Server),
           Name, type);
 
     if (Name == NULL || type == NULL)
@@ -169,6 +169,179 @@ NetGetJoinInformation(
 }
 
 
+NET_API_STATUS
+WINAPI
+NetUseAdd(
+    LMSTR UncServerName,
+    DWORD Level,
+    LPBYTE Buf,
+    LPDWORD ParmError)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName),
+          Level, Buf, ParmError);
+
+    RpcTryExcept
+    {
+        status = NetrUseAdd(UncServerName,
+                            Level,
+                            (LPUSE_INFO)Buf,
+                            ParmError);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetUseDel(
+    LMSTR UncServerName,
+    LMSTR UseName,
+    DWORD ForceCond)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName),
+          debugstr_w(UseName), ForceCond);
+
+    RpcTryExcept
+    {
+        status = NetrUseDel(UncServerName,
+                            UseName,
+                            ForceCond);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetUseEnum(
+    LMSTR UncServerName,
+    DWORD Level,
+    LPBYTE *BufPtr,
+    DWORD PreferedMaximumSize,
+    LPDWORD EntriesRead,
+    LPDWORD TotalEntries,
+    LPDWORD ResumeHandle)
+{
+    USE_ENUM_STRUCT UseEnumInfo;
+    USE_INFO_0_CONTAINER Container0;
+    USE_INFO_1_CONTAINER Container1;
+    USE_INFO_2_CONTAINER Container2;
+    NET_API_STATUS status;
+
+    TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName),
+          Level, BufPtr, PreferedMaximumSize, EntriesRead, TotalEntries, ResumeHandle);
+
+    UseEnumInfo.Level = Level;
+    switch (Level)
+    {
+        case 0:
+            UseEnumInfo.UseInfo.Level0 = &Container0;
+            Container0.EntriesRead = 0;
+            Container0.Buffer = NULL;
+            break;
+
+        case 1:
+            UseEnumInfo.UseInfo.Level1 = &Container1;
+            Container1.EntriesRead = 0;
+            Container1.Buffer = NULL;
+            break;
+
+        case 2:
+            UseEnumInfo.UseInfo.Level2 = &Container2;
+            Container2.EntriesRead = 0;
+            Container2.Buffer = NULL;
+            break;
+
+        default:
+            return ERROR_INVALID_PARAMETER;
+    }
+
+    RpcTryExcept
+    {
+        status = NetrUseEnum(UncServerName,
+                             &UseEnumInfo,
+                             PreferedMaximumSize,
+                             TotalEntries,
+                             ResumeHandle);
+        if (status == NERR_Success || status == ERROR_MORE_DATA)
+        {
+            switch (Level)
+            {
+                case 0:
+                    *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level0->Buffer;
+                    *EntriesRead = UseEnumInfo.UseInfo.Level0->EntriesRead;
+                    break;
+
+                case 1:
+                    *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level1->Buffer;
+                    *EntriesRead = UseEnumInfo.UseInfo.Level1->EntriesRead;
+                    break;
+
+                case 2:
+                    *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level2->Buffer;
+                    *EntriesRead = UseEnumInfo.UseInfo.Level2->EntriesRead;
+                    break;
+            }
+        }
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetUseGetInfo(
+    LMSTR UncServerName,
+    LMSTR UseName,
+    DWORD Level,
+    LPBYTE *BufPtr)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName),
+          debugstr_w(UseName), Level, BufPtr);
+
+    *BufPtr = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrUseGetInfo(UncServerName,
+                                UseName,
+                                Level,
+                                (LPUSE_INFO)BufPtr);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
 NET_API_STATUS
 WINAPI
 NetWkstaGetInfo(
@@ -241,8 +414,8 @@ NetWkstaUserEnum(
     LPDWORD resumehandle)
 {
     WKSTA_USER_ENUM_STRUCT UserEnumInfo;
-    WKSTA_USER_INFO_0_CONTAINER Level0;
-    WKSTA_USER_INFO_1_CONTAINER Level1;
+    WKSTA_USER_INFO_0_CONTAINER Container0;
+    WKSTA_USER_INFO_1_CONTAINER Container1;
     NET_API_STATUS status;
 
     TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
@@ -252,15 +425,15 @@ NetWkstaUserEnum(
     switch (level)
     {
         case 0:
-            UserEnumInfo.WkstaUserInfo.Level0 = &Level0;
-            UserEnumInfo.WkstaUserInfo.Level0->EntriesRead = 0;
-            UserEnumInfo.WkstaUserInfo.Level0->Buffer = NULL;
+            UserEnumInfo.WkstaUserInfo.Level0 = &Container0;
+            Container0.EntriesRead = 0;
+            Container0.Buffer = NULL;
             break;
 
         case 1:
-            UserEnumInfo.WkstaUserInfo.Level1 = &Level1;
-            UserEnumInfo.WkstaUserInfo.Level1->EntriesRead = 0;
-            UserEnumInfo.WkstaUserInfo.Level1->Buffer = NULL;
+            UserEnumInfo.WkstaUserInfo.Level1 = &Container1;
+            Container1.EntriesRead = 0;
+            Container1.Buffer = NULL;
             break;
 
         default: