首页 > 其他分享 >部署IIS后访问共享文件失败

部署IIS后访问共享文件失败

时间:2023-04-08 21:34:01浏览次数:32  
标签:GetSection IIS 部署 服务器 访问共享 StartInfo 共享 proc

   在本地调试时没有问题,但是部署到IIS后操作共享文件的时候失败,压根找不到目录。

在和共享文件服务器已经建立连接的情况下,本地调试通过的情况,猜测应该是部署后权限出现了问题,IIS 的权限不够导致的。

尝试了以下几种方法,我用第三种方法可行,可能因为我这边是内网环境,环境不同处理的方式也不太一样,简单的记录一下,仅供参考。

 

1、修改“应用程序池”下的标识为自定义账户。

这里的账户填写这台服务器的登录账户和密码,这里我配置完后重新启动应用池,报错503。  然后又网上查到需要将此账户添加到用户组下的IIS_USER组下。

添加到几个相关的用户组下后,重启服务器还是不行,仍然报错503,应用池会自动停止。 

参考:https://blog.csdn.net/yilianzj/article/details/10606801

 

2、将共享目录添加到本地(网络位置),然后使用IIS 创建虚拟目录

注意设置的特定用户需要在共享目录文件那边要有权限。

 

 参考:https://www.shuzhiduo.com/A/WpdKKwAdVQ/

 

 3、将此IIS应用池或者IIS服务器添加到共享文件权限下。

选择共享目录设置权限,把IIS服务器添加进去,我之前把服务器登录账号添加进去没起作用。在高级里面调整一下对象类型可以查找到服务器(我是在内网环境)

 参考:https://www.likecs.com/show-204583740.html

 

测试的时候把共享文件的权限设置了everyone,能是能访问的到了,但是写入内容后保存失败,文件竟然还直接被删除了.离谱...

 

连接共享文件夹方法: 

        /// <summary>
        /// 连接远程共享文件夹
        /// </summary>
        /// <param name="remoteHost">主机号(ip或主机名)</param>
        /// <returns></returns>
        public bool Connect(string remoteHost)
        {
            this.ShareDto = new ShareConfig()
            {
                RemoteHost = Config.GetSection("ShareParameter")?.GetSection("RemoteHost")?.Value,
                UserName = Config.GetSection("ShareParameter")?.GetSection("UserName")?.Value,
                Password = Config.GetSection("ShareParameter")?.GetSection("Password")?.Value,
            };
            if (string.IsNullOrWhiteSpace(remoteHost))
            {
                remoteHost = this.ShareDto.RemoteHost;
            }
            var flag = false;
            var proc = new Process();
            try
            {
                if (remoteHost.IsNullOrWhiteSpace())
                    throw new UserFriendlyException("主机号不能为空");

                proc.StartInfo.FileName = "cmd.exe";
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.RedirectStandardInput = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError = true;
                proc.StartInfo.CreateNoWindow = true;
                proc.Start();
                var host = @"\\" + remoteHost;
                var dosLine = "net use " + host + " " + this.ShareDto.Password
                    + " /user:" + this.ShareDto.UserName;
                proc.StandardInput.WriteLine(dosLine);
                proc.StandardInput.WriteLine("exit");

                while (!proc.HasExited) proc.WaitForExit(1000);

                var errormsg = proc.StandardError.ReadToEnd();
                proc.StandardError.Close();
                if (!errormsg.IsNullOrWhiteSpace())
                    throw new Exception(errormsg);

                flag = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                proc.Close();
                proc.Dispose();
            }
            return flag;
        }

 

标签:GetSection,IIS,部署,服务器,访问共享,StartInfo,共享,proc
From: https://www.cnblogs.com/LinWenQiang/p/17299231.html

相关文章

  • k8s部署prometheus
    部署到一个k8s集群gitclone-brelease-0.12https://github.com/prometheus-operator/kube-prometheus.gitcdkube-prometheusgrep"image:"./manifests/-R国内无法下载的镜像:以8s.gcr.io开头k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.5.0k8s.gcr.io/prometheu......
  • 部署node_exporter
    wgethttps://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gztarxfnode_exporter-1.5.0.linux-amd64.tar.gzrm-rf/usr/local/node_exportermvnode_exporter-1.5.0.linux-amd64/usr/local/node_exportermkd......
  • Debian系统 Docker部署
    curl-fsSLhttps://mirrors.aliyun.com/docker-ce/linux/debian/gpg|sudogpg--dearmor-o/usr/share/keyrings/docker-archive-keyring.gpgecho\"deb[arch=amd64signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]https://mirrors.aliyun.com/dock......
  • ES搜索框架--ES部署到Centos8服务器
    参考:https://blog.csdn.net/Me_xuan/article/details/114608076https://www.cnblogs.com/chenxitag/p/12320868.html一、下载安装1.下载ES使用elasticsearch7.10.2,到官网下载对应的linux包,然后上传到服务器文件夹下,cd到文件夹后使用tar命令解压tar-xvfelasticsearch-7.10.2-linu......
  • 千级边缘节点应用分钟级部署测试验证
    1.测试组网一台主节点master部署k8s,mef-center组件,cloudcore7台服务器模拟边缘节点部署docker,edgecore2.模拟边缘节点步骤2.1制作边缘容器镜像拉取官网ubuntu镜像,更新镜像源,安装docker.io,安装systemd所需要的Init重新提交docker镜像2.2执行特权容器dockerrun-......
  • flask-day5——python项目高并发异步部署、uwsgi启动python的web项目不要使用全局变量
    目录一、python项目高并发异步部署二、uwsgi启动Python的Web项目中不要使用全局变量三、信号3.1flask信号3.2django信号四、微服务的概念五、flask-script六、sqlalchemy快速使用七、sqlalchemy快速使用4.1原生操作的快速使用八、创建操作数据表九、作业1、什么是猴子补丁,有什......
  • Centos 7 安装部署 xxl-job
    1.xxl-job部署前需要的环境-Maven3+-Jdk1.8+-Mysql5.7+2.xxl-job下载地址官网地址https://www.xuxueli.com/xxl-job/源码地址https://github.com/xuxueli/xxl-job/3.在源码地址下载zip源码,下载项目源码并解压导入IDEA(maven要配置好阿里云的远程仓库,idea要配置好......
  • django/flask高并发部署
    django和flask是同步框架,部署的时候使用uwsgi部署,uwsgi是多进程多线程框架,并发量不高大概几十。我们可以通过uwsgi加gevent部署成异步程序,普通的部署方式uwsgi-x./luffyapi.xml这是使用genvent提高并发部署uwsgi--gevent50--gevent-monkey-patch./luffyapi.xml......
  • k8s前端部署
    //前端项目打包构建;支持多环境pipeline{agentanyenvironment{//GIT路径GIT_PATH="threegene/dev/zproduct/server/demo.git"//项目名称,使用Job名称作为项目名称PROJECT_NAME="${JOB_NAME}"//自定义项目名称//PROJECT_NAME="threegene-livex-center-html"//......
  • centos7 mongodb4.4分片集群部署
    #创建mongo相应的目录mkdir-pv/data/app/mongodb/confmkdir-pv/data/app/mongodb/{configset,shared1,shared2,shared3}/logmkdir-pv/data/mongodb/{configset,shared1,shared2,shared3}/data #创建于用户,给权限useradd-s/sbin/nologin-Mmongodchown-Rmong......