两台电脑,其中一台发布了asp.net应用程序,该应用程序有一功能要求上传附件到另一台电脑上,同时要求可以显示附件. give more detail stuff, guys! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在文件服务器上建一个共享的目录,允许对这个目录进行读写在web服务器上映射这个目录,读写都只针对映射驱动器要注意的是,asp.net的web.config需要配置身份模拟其他都一样 建立信任连接System.Diagnostics.Process.Start("net.exe","use \\\\10.88.60.98\\d$\\yubo \"168168\" /user:\"administrator\"");建立信任连接WIN2003public const int LOGON32_LOGON_INTERACTIVE = 2;public const int LOGON32_PROVIDER_DEFAULT = 0;WindowsImpersonationContext impersonationContext; [DllImport("advapi32.dll", CharSet=CharSet.Auto)]public static extern int LogonUser(String lpszUserName, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);[DllImport("advapi32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)]public extern static int DuplicateToken(IntPtr hToken, int impersonationLevel, ref IntPtr hNewToken);public void Page_Load(Object s, EventArgs e){ if(impersonateValidUser("username", "domain", "password")) { //Insert your code that runs under the security context of a specific user here. undoImpersonation(); } else { //Your impersonation failed. Therefore, include a fail-safe mechanism here. }}private bool impersonateValidUser(String userName, String domain, String password){ WindowsIdentity tempWindowsIdentity; IntPtr token = IntPtr.Zero; IntPtr tokenDuplicate = IntPtr.Zero; if(LogonUser(userName, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref token) != 0) { if(DuplicateToken(token, 2, ref tokenDuplicate) != 0) { tempWindowsIdentity = new WindowsIdentity(tokenDuplicate); impersonationContext = tempWindowsIdentity.Impersonate(); if (impersonationContext != null) return true; else return false; } else return false; } else return false;}private void undoImpersonation(){ impersonationContext.Undo();} 我试过了,在文件服务器上建一个共享的目录,允许对这个目录进行读写在web服务器上映射这个目录,但是最后在ASP.net应用程序里上传文件时就会弹出一个窗口要求输入用户、密码的信息(这还是一个权限问题)to icyer() : 所谓“asp.net的web.config需要配置身份模”,到底在web.config里的配置怎么写? asp.net发布网页,如何实现跨网段访问 asp.net 将查询结果保存到本地 Div内容如何自动充满? 着急着急着急!!!! 包加载失败( 打开设计界面的时候才出现这个问题,有没人解决过这个问题?) 关于jmail发送邮件的问题,请有经验的老鸟们帮帮忙 请大家帮我看看这种 Session 问题。 BS程序部署到IIS File.Move问题 请教一个问题 为什么我在窗体上加了一个datagrid不可见,他的visible属性为true 怎样将一个HttpCookie赋于一个数组??
在web服务器上映射这个目录,读写都只针对映射驱动器要注意的是,asp.net的web.config需要配置身份模拟其他都一样
System.Diagnostics.Process.Start("net.exe","use \\\\10.88.60.98\\d$\\yubo \"168168\" /user:\"administrator\"");
建立信任连接WIN2003
public const int LOGON32_LOGON_INTERACTIVE = 2;
public const int LOGON32_PROVIDER_DEFAULT = 0;WindowsImpersonationContext impersonationContext; [DllImport("advapi32.dll", CharSet=CharSet.Auto)]
public static extern int LogonUser(String lpszUserName,
String lpszDomain,
String lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken);
[DllImport("advapi32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto,
SetLastError=true)]
public extern static int DuplicateToken(IntPtr hToken,
int impersonationLevel,
ref IntPtr hNewToken);public void Page_Load(Object s, EventArgs e)
{
if(impersonateValidUser("username", "domain", "password"))
{
//Insert your code that runs under the security context of a specific user here.
undoImpersonation();
}
else
{
//Your impersonation failed. Therefore, include a fail-safe mechanism here.
}
}private bool impersonateValidUser(String userName, String domain, String password)
{
WindowsIdentity tempWindowsIdentity;
IntPtr token = IntPtr.Zero;
IntPtr tokenDuplicate = IntPtr.Zero; if(LogonUser(userName, domain, password, LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, ref token) != 0)
{
if(DuplicateToken(token, 2, ref tokenDuplicate) != 0)
{
tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);
impersonationContext = tempWindowsIdentity.Impersonate();
if (impersonationContext != null)
return true;
else
return false;
}
else
return false;
}
else
return false;
}
private void undoImpersonation()
{
impersonationContext.Undo();
}
在文件服务器上建一个共享的目录,允许对这个目录进行读写
在web服务器上映射这个目录,但是最后在ASP.net应用程序里上传文件时就会弹出一个窗口
要求输入用户、密码的信息(这还是一个权限问题)
to icyer() :
所谓“asp.net的web.config需要配置身份模”,到底在web.config里的配置怎么写?