Esempio n. 1
0
 public ICollection <IFileSystemResourceAccessor> GetChildDirectories()
 {
     if (IsRootPath(_path))
     {
         return(_parent.BrowserService.Hosts
                .Select(host => host.GetUncString()).Where(uncPathString => uncPathString != null)
                .Select(uncPathString => new NetworkNeighborhoodResourceAccessor(_parent, uncPathString.Replace('\\', '/')))
                .Cast <IFileSystemResourceAccessor>().ToList());
     }
     using (ImpersonateUser(_impersonationContext))
     {
         if (IsServerPath(_path))
         {
             return(SharesEnumerator.EnumerateShares(StringUtils.RemovePrefixIfPresent(_path, "//"))
                    // Allow all filesystems, but exclude "Special" shares (IPC, Admin$)
                    .Where(share => share.IsFileSystem && !share.ShareType.HasFlag(ShareType.Special))
                    .Select(
                        share =>
             {
                 try { return new NetworkNeighborhoodResourceAccessor(_parent, share.UNCPath.Replace('\\', '/')); }
                 catch (IllegalCallException) { return null; }
             }
                        ).Where(share => share != null && share.Exists).Cast <IFileSystemResourceAccessor>().ToList()); // "share.Exists" considers the user's access rights.
         }
         return(_underlayingResource == null ? null : WrapLocalFsResourceAccessors(_underlayingResource.GetChildDirectories()));
     }
 }
Esempio n. 2
0
 public ICollection <IFileSystemResourceAccessor> GetChildDirectories()
 {
     if (IsRootPath(_path))
     {
         return(_parent.BrowserService.Hosts
                .Select(host => host.GetUncString()).Where(uncPathString => uncPathString != null)
                .Select(uncPathString => new NetworkNeighborhoodResourceAccessor(_parent, uncPathString.Replace('\\', '/')))
                .Cast <IFileSystemResourceAccessor>().ToList());
     }
     using (ServiceRegistration.Get <IImpersonationService>().CheckImpersonationFor(CanonicalLocalResourcePath))
     {
         if (IsServerPath(_path))
         {
             return(SharesEnumerator.EnumerateShares(StringUtils.RemovePrefixIfPresent(_path, "//"))
                    // Allow all filesystems, but exclude "Special" shares (IPC$, Admin$) and all other "hidden" shares (ending with "$" such as print$)
                    .Where(share => share.IsFileSystem && !share.ShareType.HasFlag(ShareType.Special) && !share.UNCPath.EndsWith("$"))
                    .Select(
                        share =>
             {
                 try { return new NetworkNeighborhoodResourceAccessor(_parent, share.UNCPath.Replace('\\', '/')); }
                 catch (IllegalCallException) { return null; }
             }
                        ).Where(share => share != null && share.Exists).Cast <IFileSystemResourceAccessor>().ToList()); // "share.Exists" considers the user's access rights.
         }
         var childDirectories = _underlayingResource == null ? null : _underlayingResource.GetChildDirectories();
         return(childDirectories == null ? null : WrapLocalFsResourceAccessors(childDirectories));
     }
 }
 public ICollection <IFileSystemResourceAccessor> GetChildDirectories()
 {
     if (_path == "/")
     {
         return(NetworkResourcesEnumerator.EnumerateResources(ResourceScope.GlobalNet, ResourceType.Disk,
                                                              ResourceUsage.All, ResourceDisplayType.Server).Select(
                    serverName => new NetworkNeighborhoodResourceAccessor(
                        _parent, StringUtils.CheckPrefix(serverName, @"\\").Replace('\\', '/'))).Cast <IFileSystemResourceAccessor>().ToList());
     }
     if (IsServerPath(_path))
     {
         return(SharesEnumerator.EnumerateShares(StringUtils.RemovePrefixIfPresent(_path, "//")).Where(
                    share => share.ShareType == ShareType.Disk).Select(
                    share => {
             try { return new NetworkNeighborhoodResourceAccessor(_parent, share.UNCPath.Replace('\\', '/')); }
             catch (IllegalCallException) { return null; }
         }
                    ).Where(share => share != null).Cast <IFileSystemResourceAccessor>().ToList());
     }
     return(_underlayingResource == null ? null : WrapLocalFsResourceAccessors(_underlayingResource.GetChildDirectories()));
 }