首页 \ 问答 \ PHP或Java确认用户是否可以访问网络驱动器上的特定文件夹(PHP or Java Confirm if user has access to a specific folder on a network drive)

PHP或Java确认用户是否可以访问网络驱动器上的特定文件夹(PHP or Java Confirm if user has access to a specific folder on a network drive)

当用户访问内部网络网站上的特定页面时,我需要检查他们是否可以访问非常特定的网络文件夹。 我需要像is_readable()那样运行的东西,但是从用户系统的角度而不是从服务器。

基本上,如果您具有访问特殊文件夹的网络权限,则该站点是可访问的。 如果不是,您将被拒绝访问。 这是避免用户登录系统的快速而肮脏的方法。 它捎带在网络安全上,而不实际与它集成。

我不介意在PHP或Java中这样做。 有任何想法吗?


When the user goes to a specific page on an internal network website I need to check if they user has access to a very specific network folder. I need something that operates like is_readable() but from the users system perspective and not from the server.

Basically if you have network priviledges to access a special folder then the site is accessable. If not you are denied access. It's a quick and dirty way to avoid a user login system. It piggy backs on the networks security without actually integrating with it.

I don't mind doing this in PHP or Java. Any ideas?


原文:https://stackoverflow.com/questions/13462674
更新时间:2023-07-27 16:07

最满意答案

我猜你的问题是#mapCanvas不在DOM中,直到你尝试访问它,所以这个:

document.getElementById('mapCanvas')

会给你一个无用的null 。 在使用之前,您需要等待#mapCanvas在DOM中; 你不能做这样的事情:

map_canvas = this.$el.find('#mapCanvas')[0];

这会给你一个有效的ID,但你会混淆谷歌地图的功能,因为它不会有一个大小,所以地图将呈现奇怪。 这会让您回想起在绑定您的Google地图资料之前等待DOM中的所有内容。

解决这个问题的一个方法是使用延迟为零的setTimeout

var _this = this;
setTimeout(function() { _this.renderMap() }, 0);

这看起来有点奇怪,但这个技巧基本上会将renderMap调用转储到浏览器的工作队列中,并且一旦将控制权返回给浏览器,它就会运行。

你也可以使用_.defer

推迟 _.defer(function, [*arguments])

延迟调用函数,直到当前调用堆栈已被清除,类似于使用延迟为0的setTimeout 。用于执行昂贵的计算或块中的HTML渲染,而不阻止UI线程更新。

这可能是一个更好的选择,因为它使你的意图明确。


I'd guess that your problem is that #mapCanvas isn't in the DOM until after you try to access it so this:

document.getElementById('mapCanvas')

will give you a useless null. You need to wait until #mapCanvas is in the DOM before using it; you can't do something like this either:

map_canvas = this.$el.find('#mapCanvas')[0];

That will give you a valid ID but you'll confuse the Google Maps functions because it won't have a size so the map will be rendered oddly. This puts you back to waiting for everything to be in the DOM before binding your Google Maps stuff.

One way around this is to use setTimeout with a delay of zero:

var _this = this;
setTimeout(function() { _this.renderMap() }, 0);

This looks strange bit it does work, this trick basically dumps your renderMap call into the browser's work queue and it'll get around to running it once you've returned control to the browser.

You can also use _.defer:

defer _.defer(function, [*arguments])

Defers invoking the function until the current call stack has cleared, similar to using setTimeout with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without blocking the UI thread from updating.

This might be a better choice as it makes your intent explicit.

相关问答

更多
  • 我猜你的问题是#mapCanvas不在DOM中,直到你尝试访问它,所以这个: document.getElementById('mapCanvas') 会给你一个无用的null 。 在使用之前,您需要等待#mapCanvas在DOM中; 你不能做这样的事情: map_canvas = this.$el.find('#mapCanvas')[0]; 这会给你一个有效的ID,但你会混淆谷歌地图的功能,因为它不会有一个大小,所以地图将呈现奇怪。 这会让您回想起在绑定您的Google地图资料之前等待DOM中的所 ...
  • 使用mapElement 打字稿文件 let minZoomLevel = 12; let mapOptions = { zoom: minZoomLevel, center: new google.maps.LatLng(38.50, -90.50), mapTypeId: google.maps.MapTypeId.ROADMAP } this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions); ...
  • 这个问题通常是由于在需要访问JavaScript的JavaScript运行之前,地图div没有被渲染。 您应该将初始化代码放在一个onload函数或HTML文件的底部,就在标签之前,所以DOM在执行之前完全呈现(注意第二个选项对无效的HTML更为敏感)。 注意,如matthewsheets所指出的,这也可能是由于该div的原因而不是HTML中的所有id(div的病理情况未被呈现) 从wf9a5m75的帖子添加代码示例将所有内容放在一个位置: