NetShareEnum在Windows的Docker容器内返回2114(NERR_ServerNotStarted)

时间:2018-11-21 00:02:57

标签: windows docker winapi networking windows-services

在Windows上的Docker容器(基于mcr.microsoft.com/windows/servercore:1803映像)中调用NetShareEnum时,我得到了NERR_ServerNotStarted作为返回值。这是产生错误的最小示例代码:

#include <stdio.h>

#include <windows.h>
#include <lm.h>

int main()
{
    PSHARE_INFO_502 buffer;
    DWORD entriesRead, totalEntries, resume = 0;
    NET_API_STATUS result = NetShareEnum(NULL, 502, (LPBYTE*)&buffer, MAX_PREFERRED_LENGTH,
        &entriesRead, &totalEntries, &resume);
    if (result != ERROR_SUCCESS && result != ERROR_MORE_DATA)
    {
        printf("NetShareEnum error: %08x (%u)\n", result, result);
        return 1;
    }

    printf("All good!\n");
    NetApiBufferFree(buffer);

    return 0;
}

输出:

NetShareEnum error: 00000842 (2114)

其他信息级别(例如2或0)也发生了同样的情况。请注意,网络本身在容器内正常工作(我可以访问网络资源和其他计算机),并且与该特定问题无关。

我希望您能对问题的确切含义以及是否有可能适当地解决它或至少以某种方式解决它有任何见解。谢谢。


编辑:尝试运行LanmanServer,希望它是我所需要的:

PS C:\> Start-Service LanmanServer
Start-Service : Failed to start service 'Server (LanmanServer)'.
At line:1 char:1
+ Start-Service LanmanServer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException
    + FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand

PS C:\> Get-EventLog System -Newest 1 | fl


Index              : 603
EntryType          : Error
InstanceId         : 3221232495
Message            : The Server service terminated with the following error:
                     %%2
Category           : (0)
CategoryNumber     : 0
ReplacementStrings : {Server, %%2}
Source             : Service Control Manager
TimeGenerated      : 11/20/2018 4:23:59 PM
TimeWritten        : 11/20/2018 4:23:59 PM
UserName           :

0 个答案:

没有答案