[fixed] [4378] Issues accessing network share using the service (4 Viewers)

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    I've found some time to implement the "caching" of impersonation inside RA instance. I also check in subsequent calls if impersonation is (again) required and revert identity on instance in Dispose().

    Please check if this version works for you. It also should not cause major delays because of avoiding to many Impersonate() calls.
     

    Attachments

    • NetworkNeighborhoodResourceProvider_v3.7z
      7 KB
    Last edited:

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Ooops. typed too slow - will test your implementation right away...

    Hi there,

    just tested your Provider.dll above, Morpheus. The result is very strange.
    1. It is really very slow - from the log the Import of one complete Audio CD as MP3-files takes between 10sec and 20 sec. Between MP2-Server and share is a 54MBit WLan - not really fast, but the Import shouldn't be THAT slow...
    2. It doesn't Import all the files. There is no error in the log, just the lines from the ImportWorker (...xy resources pending...). But although there should already be 200 Music files imported, MP2-client only Shows 35 Songs. I can't find any pattern on which are imported and which are not.
    Really strange...

    But maybe we are thinking too complicated here. Another idea:

    We Need impersonation to be able to see the other Computers in the Network and the Shares of the respective Computers. But for anything below (folers and files on the Shares), we don't really Need impersonation. We just have to connect to the respective share just as we do with NET USE. In c# this can be done via a pInvoke of the WNetAddConnection2 method (http://msdn.microsoft.com/en-us/library/windows/desktop/aa385413(v=vs.85).aspx).
    When my understanding is correct, the big Advantage would be that this does not depend on threads. The Connection depends on the user - which means we would have to establish this Connection when we are (still or again) the Service user. We don't have to specify a local drive letter - just establish the Connection without it.
    Estblishing a Connection when it already exists is also not a Problem - it is even faster than when the Connection was actually established (try with multiple "NET USE \\COMUPTER\SHARE" on the console). Ideally, we could even store in the ResourceProvider the strings of the Share connections, which have already been established and only call WNetAddConnection2 in the accessor if this hasn't been done before for this share.

    The big Advantage in my opinion is that this can all be done in the constructor, because the properties can only be accessed by whatever threads after the constructor has been called. Finally, Connections without a local drive letter are not persistent - i.e. after a reboot at the latest, we are clean again.

    So in the constructor, we would just check:
    If it's root or a serverPath
    do nothing​
    else
    if share Connection was not already established​
    WNetAddConnection2​

    Impersonation is then only needed in GetChildDirectories() for root and serverPaths to make sure that the enumeration of Computers and Shares works.

    Does that make sense?
    Michael
     
    Last edited:

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    I know about WNetAddConnection2 , used it before in other project. My primary intention was that the user must not be forced to enter username/password again if it is not really required. That's why I took the impersonation way first.

    So let's see if last snapshot improves situation (I think and hope so ;))
     
    Last edited:

    Lehmden

    Retired Team Member
  • Premium Supporter
  • December 17, 2010
    12,562
    3,944
    Lehmden
    Home Country
    Germany Germany
    Hi.
    V3 is working here, great! ;) Now I can import Media while server is running as service... Speed also is at normal state, no delays...
    Server Settings are "Use username and Password to access" enabled. Maybe I'll try to add a share without those...

    What a big improvement the last days. First a great working SQLite Plugin and now a great working NetworkNeighborhoodResourceProvider plugin...
     
    Last edited:

    Lehmden

    Retired Team Member
  • Premium Supporter
  • December 17, 2010
    12,562
    3,944
    Lehmden
    Home Country
    Germany Germany
    Hi Tried it without any Username and password in server settings. This did not work. But if I have checked one of the two options, no matter which one it's working. And I can check both, this works too...
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Nope, sorry, doesn't work...
    After chosing the NetworkNeighborhoodResourceProvider when trying to add a share, nothing is shown - no Computers at all in the list.
    ServerLog Shows:
    [2013-04-29 22:16:16,700] [190062 ] [26 ] [WARN ] - DvArgument: Error serializing argument value
    MediaPortal.Utilities.Exceptions.InvalidDataException: UPnPDtResourcePathMetadataEnumeration: Invalid null value
    bei UPnP.Infrastructure.Common.UPnPExtendedDataType.SoapSerializeValue(Object value, Boolean forceSimpleValue, XmlWriter writer) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Common\UPnPExtendedDataType.cs:Zeile 137.
    bei UPnP.Infrastructure.Dv.DeviceTree.DvExtendedDataType.SoapSerializeValue(Object value, Boolean forceSimpleValue, XmlWriter writer) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\DeviceTree\DvExtendedDataType.cs:Zeile 72.
    bei UPnP.Infrastructure.Dv.DeviceTree.DvArgument.SoapSerializeArgument(Object value, Boolean forceSimpleValue, XmlWriter writer) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\DeviceTree\DvArgument.cs:Zeile 136.
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    Hmm, seems like I'm too dumb to use it... :p

    @Lehmnden, could you please try to add another sharer with Morpheus' v3 and check whether you can see other Computers and/or Shares?
    I assume you still had the share configured before you changed the Provider.dll?

    Thanks!
     

    MJGraf

    Retired Team Member
  • Premium Supporter
  • January 13, 2006
    2,478
    1,385
    The above was with Username/Password.

    When I select credentials of interactive session and try to add a share Server log Looks like:

    [2013-04-29 22:26:09,825] [783187 ] [18 ] [WARN ] - SOAPHandler: Error invoking UPnP action 'DoesResourceProviderSupportTreeListing'
    System.ComponentModel.Win32Exception (0x80004005): Zugriff verweigert
    bei System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
    bei System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
    bei System.Diagnostics.Process.OpenProcessHandle(Int32 access)
    bei System.Diagnostics.Process.get_Handle()
    bei MediaPortal.Extensions.ResourceProviders.NetworkNeighborhoodResourceProvider.Impersonate.ImpersonationHelper.ImpersonateByProcess(String processName, WindowsIdentity& user)
    bei MediaPortal.Extensions.ResourceProviders.NetworkNeighborhoodResourceProvider.NetworkNeighborhoodResourceAccessor.ImpersonateUser(WindowsIdentity& requestedIdentity)
    bei MediaPortal.Extensions.ResourceProviders.NetworkNeighborhoodResourceProvider.NetworkNeighborhoodResourceAccessor.IsResource(String path)
    bei MediaPortal.Extensions.ResourceProviders.NetworkNeighborhoodResourceProvider.NetworkNeighborhoodResourceProvider.IsResource(String path)
    bei MediaPortal.Extensions.ResourceProviders.NetworkNeighborhoodResourceProvider.NetworkNeighborhoodResourceProvider.TryCreateResourceAccessor(String path, IResourceAccessor& result)
    bei MediaPortal.Common.Services.ResourceAccess.UPnPResourceInformationServiceImpl.OnDoesResourceProviderSupportTreeListing(DvAction action, IList`1 inParams, IList`1& outParams, CallContext context) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\MediaPortal.Common\Services\ResourceAccess\UPnPResourceInformationServiceImpl.cs:Zeile 456.
    bei UPnP.Infrastructure.Dv.DeviceTree.DvAction.FireActionInvoked(IList`1 inParams, IList`1& outParams, CallContext context) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\DeviceTree\DvAction.cs:Zeile 146.
    bei UPnP.Infrastructure.Dv.DeviceTree.DvAction.InvokeAction(IList`1 inParameters, IList`1& outParameters, Boolean checkSignature, CallContext context) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\DeviceTree\DvAction.cs:Zeile 129.
    bei UPnP.Infrastructure.Dv.SOAP.SOAPHandler.HandleRequest(DvService service, Stream messageStream, Encoding streamEncoding, Boolean subscriberSupportsUPnP11, CallContext context, String& result) in c:\_MP\Quellcode\MediaPortal-2\MediaPortal\Source\Core\UPnP\Infrastructure\Dv\SOAP\SOAPHandler.cs:Zeile 155.
     

    Lehmden

    Retired Team Member
  • Premium Supporter
  • December 17, 2010
    12,562
    3,944
    Lehmden
    Home Country
    Germany Germany
    Did you replace both dll? (in MP2 Server\plugins and MP2-Client\Plugins)
     

    Lehmden

    Retired Team Member
  • Premium Supporter
  • December 17, 2010
    12,562
    3,944
    Lehmden
    Home Country
    Germany Germany
    I can add shares, remove shares, reimport shares without any issue. All pc in my workgroup are shown...
    On this screenshot 3 PC are online, Kirk, Spock and Pille...
    Shares.jpg
     

    Users who are viewing this thread

    Top Bottom