System.IO.Directory.CreateDirectory(@"\\youserver\web\123456"); 报错!!!!!
未找到路径“\\youserver\web”的一部分。
已经映射,已经登陆,操作系统可以建立,但我的程序为什么建立不了???c#是使用的什么身份??
使用System.IO.Directory.CreateDirectory建立UNC目录,应该怎么建立???要用模拟身份吗??
应该没这么麻烦吧??
请老大指点^^^^
未找到路径“\\youserver\web”的一部分。
已经映射,已经登陆,操作系统可以建立,但我的程序为什么建立不了???c#是使用的什么身份??
使用System.IO.Directory.CreateDirectory建立UNC目录,应该怎么建立???要用模拟身份吗??
应该没这么麻烦吧??
请老大指点^^^^
解决方案 »
- win7与VS 2008 兼容问题..知道的麻烦帮下忙,谢谢了
- C# 文本文件读出...
- Linq中如何写入含有双引号与单引号的数据
- 为什么DataGrid 要按删除按钮两次 才可以删除
- 求水晶报表打印高手,帮忙!
- 重写WndProc后,如何避免当当当的声音
- c# splitcontainer
- windows服务Marshal.GetActiveObject(progID)方法获取word进程
- 新手刚来,想求一个免费的或者便宜的(100块以下)通用验证码识别控件。。
- 求教,有什么比较好的关系系统架构设计方面的书啊?
- SQL优化插入记录的问题
- ADO.NET访问SQL Server,但是从Enterprise Manager/Management/Current Activity/Locks Process ID看到多个进程被锁!
你的是不是ASP.NET程序?执行WEB程序的用户是ASPNET,默认没有IO权限,你得自己加
我的环境是 win2003+IIS6权限怎么加啊??? IIS6中好象不是ASPNET,好象是NETWORK SERVICE 不太懂,能说清楚点吗??
对!
System.IO.Directory.CreateDirectory(@"\\youserver\web\123456"); 报错!!!!!
未找到路径“\\youserver\web”的一部分。
http://www.cnblogs.com/dahuaidan410/archive/2004/10/27/57471.aspx但我不会使用啊,我是在局域网里操作
public static void ImpersonateAndDo(string UserName, string PWD, ImpersonatedWork WhatToDo)
这里面的参数应该怎么加???? B机器里的用户Administrator PWD= 123456 机器名=book 总是抱错: 1326 87 ………………
WindowsImpersonationContext wic=CreateIdentity(
username, domain,
pwd ).Impersonate();
总是报错 LogonUser failed with error code: " 132…… 为什么???CODE:[DllImport("advapi32.dll", SetLastError=true)]
private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
private extern static bool CloseHandle(IntPtr handle);
protected static WindowsIdentity CreateIdentity(string User, string Domain, string Password)
{
// The Windows NT user token.
IntPtr tokenHandle = new IntPtr(0);
const int LOGON32_PROVIDER_DEFAULT = 0;
const int LOGON32_LOGON_NETWORK = 3;
tokenHandle = IntPtr.Zero;
// Call LogonUser to obtain a handle to an access token.
bool returnValue = LogonUser(User, Domain, Password,
LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT,
ref tokenHandle);
if (false == returnValue)
{
int ret = Marshal.GetLastWin32Error();
throw new Exception("LogonUser failed with error code: " + ret);
}
//The WindowsIdentity class makes a new copy of the token.
//It also handles calling CloseHandle for the copy.
WindowsIdentity id = new WindowsIdentity(tokenHandle);
CloseHandle(tokenHandle);
return id;
}用法:
WindowsImpersonationContext wic=CreateIdentity(
username, domain,
pwd ).Impersonate();
//做那些需要权限的操作wic.Undo();我们的思归大哥哪去了??????????????????????
the truth is that when different user visit your application,the io operation will regard them as different users ,not aspnet ,iis_anonymous or assigned computer account on the goal computer.
谢谢您可我要操作好多台服务器,不能每台都要做个Webservice吧我的环境: 一台管理平台电脑, 多台服务器, 要自动批量建立目录,用户.用户可以用WMI建立,但目录不知道怎么用WMI建立 帮忙