文件夹的完全控制权限赋给aspnet用户(ntfs,cacls)
来源:互联网 发布:金蝶k3数据字典 下载 编辑:程序博客网 时间:2024/04/27 22:00
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.DirectoryServices;
using System.Collections;
using System.Diagnostics;
using System.Management;
namespace GrantUserWritableFile
...{
public class GrantUser
...{
private string directoryInstr = "";
private string directoryPrtfl = "";
private string hostName = "";
public string DomainName = "localhost";
private string userName = "";
private string syspath = "";
private string DriverName = "";
public static void Main(string[] args)
...{
GrantUser gu = new GrantUser();
gu.getInfo();
Console.WriteLine("Grant folder to user complited!");
}
public void getInfo()
...{
DirectoryEntry de = new DirectoryEntry("IIS://Localhost/W3SVC/1/ROOT/RPA");
this.directoryInstr = (string)de.Properties["Path"].Value + "/InstrumentInfo/ChartImages";
this.directoryPrtfl = (string)de.Properties["Path"].Value + "/PortfolioView/ChartImages";
//this.directoryInstr = "C:/1";
DriverName = de.Properties["Path"].Value.ToString().Substring(0, 2);
this.hostName = Dns.GetHostName().ToString();
this.userName = "IUSR_" + hostName;
this.syspath = Environment.SystemDirectory + "/";
ManagementObjectSearcher DiskSearch = new ManagementObjectSearcher(new SelectQuery("Select * from Win32_LogicalDisk"));
ManagementObjectCollection moDiskCollection = DiskSearch.Get();
foreach (ManagementObject mo in moDiskCollection)
...{
if ((mo.SystemProperties["FileSystem"].Value.ToString().ToUpper() == "NTFS") && (DriverName == mo.SystemProperties["name"].Value.ToString()))
...{
this.SetFolder(directoryInstr, userName);
this.SetFolder(directoryPrtfl, userName);
}
}
}
public void SetFolder(string PathName,string userName)
...{
//if (Directory.Exists(PathName) == true)
//{
// Directory.Delete(PathName, true);
//}
//Directory.CreateDirectory(PathName);
Process process = new Process();
process.StartInfo.FileName = syspath + "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.StandardInput.WriteLine(String.Format("cacls {0} /t /e /g {1}:f", PathName, userName));
process.StandardInput.WriteLine("exit");
process.WaitForExit();
process.Close();
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.DirectoryServices;
using System.Collections;
using System.Diagnostics;
using System.Management;
namespace GrantUserWritableFile
...{
public class GrantUser
...{
private string directoryInstr = "";
private string directoryPrtfl = "";
private string hostName = "";
public string DomainName = "localhost";
private string userName = "";
private string syspath = "";
private string DriverName = "";
public static void Main(string[] args)
...{
GrantUser gu = new GrantUser();
gu.getInfo();
Console.WriteLine("Grant folder to user complited!");
}
public void getInfo()
...{
DirectoryEntry de = new DirectoryEntry("IIS://Localhost/W3SVC/1/ROOT/RPA");
this.directoryInstr = (string)de.Properties["Path"].Value + "/InstrumentInfo/ChartImages";
this.directoryPrtfl = (string)de.Properties["Path"].Value + "/PortfolioView/ChartImages";
//this.directoryInstr = "C:/1";
DriverName = de.Properties["Path"].Value.ToString().Substring(0, 2);
this.hostName = Dns.GetHostName().ToString();
this.userName = "IUSR_" + hostName;
this.syspath = Environment.SystemDirectory + "/";
ManagementObjectSearcher DiskSearch = new ManagementObjectSearcher(new SelectQuery("Select * from Win32_LogicalDisk"));
ManagementObjectCollection moDiskCollection = DiskSearch.Get();
foreach (ManagementObject mo in moDiskCollection)
...{
if ((mo.SystemProperties["FileSystem"].Value.ToString().ToUpper() == "NTFS") && (DriverName == mo.SystemProperties["name"].Value.ToString()))
...{
this.SetFolder(directoryInstr, userName);
this.SetFolder(directoryPrtfl, userName);
}
}
}
public void SetFolder(string PathName,string userName)
...{
//if (Directory.Exists(PathName) == true)
//{
// Directory.Delete(PathName, true);
//}
//Directory.CreateDirectory(PathName);
Process process = new Process();
process.StartInfo.FileName = syspath + "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.StandardInput.WriteLine(String.Format("cacls {0} /t /e /g {1}:f", PathName, userName));
process.StandardInput.WriteLine("exit");
process.WaitForExit();
process.Close();
}
}
}
- 文件夹的完全控制权限赋给aspnet用户(ntfs,cacls)
- MAC将根目录文件夹的权限赋给用户
- Linux 虚拟机 给用户 赋某个文件夹操作的权限
- 给用户赋权限
- 赋权限给oralce新建的用户
- cacls批量权限控制
- Mysql给用户赋权限
- 给用户赋sudo权限
- C#修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限
- C#修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限
- C#修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限
- C#修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限
- C#修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限
- 关于ASPNET用户的权限
- cacls命令设置文件及其文件夹权限的方法
- oracle 下给另一个用户赋权限
- Oracle:SQL语句--给用户赋权限
- oracle 数据库的创建用户,用户解锁,给用户赋连接,资源权限的命令
- Aqua Data Studio 初用手记
- 考研过后在CSDN写blog来管理个人日常信息,文档
- 何为换手率
- 清除无法显示隐藏文件的病毒
- 熊猫烧香集体"自杀"新变种情人节爆发威胁大增
- 文件夹的完全控制权限赋给aspnet用户(ntfs,cacls)
- 腾讯QQ2007 beta1┊解决Windows Vista下QQ基本的兼容性问题┊纯净绿色特别版
- 我也要开始做一个博客了!
- 接触CAS(一)
- 2007年2月8日
- 年后要找第一份工作了
- XML 问题: 超越 DOM
- 一个用iframe遮盖select例子
- 曾经沧海难为水---物是人非的母校校园风光