共享目录开放了读写权限,两台计算机的GUEST用户都开了,网络绝对没有问题
然后,在ASP.net里编写了如下非常简单的C#脚本:
StreamReader sr = File.OpenText("\\\\yjsc\\Res\\2.txt");
TextBox1.Text = sr.ReadToEnd();
sr.Close();
脚本中的文件串如果换成本地的则完全没有问题,换成现在这个,就提示:
"未知的用户名或错误密码"
所以问题一定出在访问网络计算机和网络文件的方法上
但是不知道怎么解决
试过映射虚拟盘符的方法,不管用,而且不想使用那样的方法.
请各位老大帮帮忙呀,来顶就有分
不说了,我现在正在哭......
11 个解决方案
#1
#2
顶!
关注!
没试过!
关注!
没试过!
#3
我现在很迷茫呀,有没有高手在呀
其实这个问题是很广泛存在的一个问题呀
那位高手帮忙呀,我在这里鞠躬了~~~~~~
其实这个问题是很广泛存在的一个问题呀
那位高手帮忙呀,我在这里鞠躬了~~~~~~
#4
System.Diagnostics.Process.Start("net.exe","use \\\\dr\\ipc$ \"1234\" /user:\"administratror\"")
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
#5
在你的操作前运行一下:
System.Diagnostics.Process.Start("net.exe","use \\\\dr\\ipc$ \"1234\" /user:\"administratror\"")
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
System.Diagnostics.Process.Start("net.exe","use \\\\dr\\ipc$ \"1234\" /user:\"administratror\"")
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
#6
#7
up
#8
要调整一下当前线程的身份令牌,下面是示范代码(从MSDN Copy来的,事实上只要你认真看MSDN,几乎没什么找不到答案的问题):
The following code example shows how to set and retrieve the principal of a thread.
[Visual Basic]
Option Explicit
Option Strict
Imports Microsoft.VisualBasic
Imports System
Imports System.Security
Imports System.Security.Permissions
Imports System.Security.Principal
Imports System.Threading
' Request permission to set thread principal.
<Assembly: SecurityPermissionAttribute( _
SecurityAction.RequestOptional, ControlPrincipal := True)>
Public Class Principal
Shared Sub Main()
Dim rolesArray As String() = {"managers", "executives"}
Try
' Set the principal to a new generic principal.
Thread.CurrentPrincipal = _
New GenericPrincipal(New GenericIdentity( _
"Bob", "Passport"), rolesArray)
Catch secureException As SecurityException
Console.WriteLine("{0}: Permission to set Principal " & _
"is denied.", secureException.GetType().Name)
End Try
Dim threadPrincipal As IPrincipal = Thread.CurrentPrincipal
Console.WriteLine( _
"Name: {0}" & vbCrLf & "IsAuthenticated:" & _
" {1}" & vbCrLf & "AuthenticationType: {2}", _
threadPrincipal.Identity.Name, _
threadPrincipal.Identity.IsAuthenticated, _
threadPrincipal.Identity.AuthenticationType)
End Sub
End Class
[C#]
using System;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using System.Threading;
// Request permission to set thread principal.
[assembly: SecurityPermissionAttribute(
SecurityAction.RequestOptional, ControlPrincipal = true)]
class Principal
{
static void Main()
{
string[] rolesArray = {"managers", "executives"};
try
{
// Set the principal to a new generic principal.
Thread.CurrentPrincipal =
new GenericPrincipal(new GenericIdentity(
"Bob", "Passport"), rolesArray);
}
catch(SecurityException secureException)
{
Console.WriteLine("{0}: Permission to set Principal " +
"is denied.", secureException.GetType().Name);
}
IPrincipal threadPrincipal = Thread.CurrentPrincipal;
Console.WriteLine("Name: {0}\nIsAuthenticated: {1}" +
"\nAuthenticationType: {2}",
threadPrincipal.Identity.Name,
threadPrincipal.Identity.IsAuthenticated,
threadPrincipal.Identity.AuthenticationType);
}
}
The following code example shows how to set and retrieve the principal of a thread.
[Visual Basic]
Option Explicit
Option Strict
Imports Microsoft.VisualBasic
Imports System
Imports System.Security
Imports System.Security.Permissions
Imports System.Security.Principal
Imports System.Threading
' Request permission to set thread principal.
<Assembly: SecurityPermissionAttribute( _
SecurityAction.RequestOptional, ControlPrincipal := True)>
Public Class Principal
Shared Sub Main()
Dim rolesArray As String() = {"managers", "executives"}
Try
' Set the principal to a new generic principal.
Thread.CurrentPrincipal = _
New GenericPrincipal(New GenericIdentity( _
"Bob", "Passport"), rolesArray)
Catch secureException As SecurityException
Console.WriteLine("{0}: Permission to set Principal " & _
"is denied.", secureException.GetType().Name)
End Try
Dim threadPrincipal As IPrincipal = Thread.CurrentPrincipal
Console.WriteLine( _
"Name: {0}" & vbCrLf & "IsAuthenticated:" & _
" {1}" & vbCrLf & "AuthenticationType: {2}", _
threadPrincipal.Identity.Name, _
threadPrincipal.Identity.IsAuthenticated, _
threadPrincipal.Identity.AuthenticationType)
End Sub
End Class
[C#]
using System;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using System.Threading;
// Request permission to set thread principal.
[assembly: SecurityPermissionAttribute(
SecurityAction.RequestOptional, ControlPrincipal = true)]
class Principal
{
static void Main()
{
string[] rolesArray = {"managers", "executives"};
try
{
// Set the principal to a new generic principal.
Thread.CurrentPrincipal =
new GenericPrincipal(new GenericIdentity(
"Bob", "Passport"), rolesArray);
}
catch(SecurityException secureException)
{
Console.WriteLine("{0}: Permission to set Principal " +
"is denied.", secureException.GetType().Name);
}
IPrincipal threadPrincipal = Thread.CurrentPrincipal;
Console.WriteLine("Name: {0}\nIsAuthenticated: {1}" +
"\nAuthenticationType: {2}",
threadPrincipal.Identity.Name,
threadPrincipal.Identity.IsAuthenticated,
threadPrincipal.Identity.AuthenticationType);
}
}
#9
关键看
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("Bob", "Passport"), rolesArray);
这一句。
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("Bob", "Passport"), rolesArray);
这一句。
#10
不过你要改一下程序,用WindowsPrincipal才行。
#11
adminyao(程序*)的方法挺好用,谢谢啦
Miracle(新一代的开山怪)的方法好像和我的问题不太一样啊,我没看明白呀
最近这些天一直在忙项目,没有时间上CSDN,忽然来看看,有这么多朋友在帮助我,真的是很感动啊,在这里一并谢过啦
如果哪位兄弟有“不用net命令”的解决方法的话,请发CSDN的短信息给我,我会新开一个窗口,同样是一百分!
在这里先谢啦!!!
再次谢过以上的几位兄弟。
本贴结贴
Miracle(新一代的开山怪)的方法好像和我的问题不太一样啊,我没看明白呀
最近这些天一直在忙项目,没有时间上CSDN,忽然来看看,有这么多朋友在帮助我,真的是很感动啊,在这里一并谢过啦
如果哪位兄弟有“不用net命令”的解决方法的话,请发CSDN的短信息给我,我会新开一个窗口,同样是一百分!
在这里先谢啦!!!
再次谢过以上的几位兄弟。
本贴结贴
#1
#2
顶!
关注!
没试过!
关注!
没试过!
#3
我现在很迷茫呀,有没有高手在呀
其实这个问题是很广泛存在的一个问题呀
那位高手帮忙呀,我在这里鞠躬了~~~~~~
其实这个问题是很广泛存在的一个问题呀
那位高手帮忙呀,我在这里鞠躬了~~~~~~
#4
System.Diagnostics.Process.Start("net.exe","use \\\\dr\\ipc$ \"1234\" /user:\"administratror\"")
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
#5
在你的操作前运行一下:
System.Diagnostics.Process.Start("net.exe","use \\\\dr\\ipc$ \"1234\" /user:\"administratror\"")
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
System.Diagnostics.Process.Start("net.exe","use \\\\dr\\ipc$ \"1234\" /user:\"administratror\"")
对应修改一下即可
"use \\\\...\\....$ \"....\" /user:\"......\""对应替换掉
#6
#7
up
#8
要调整一下当前线程的身份令牌,下面是示范代码(从MSDN Copy来的,事实上只要你认真看MSDN,几乎没什么找不到答案的问题):
The following code example shows how to set and retrieve the principal of a thread.
[Visual Basic]
Option Explicit
Option Strict
Imports Microsoft.VisualBasic
Imports System
Imports System.Security
Imports System.Security.Permissions
Imports System.Security.Principal
Imports System.Threading
' Request permission to set thread principal.
<Assembly: SecurityPermissionAttribute( _
SecurityAction.RequestOptional, ControlPrincipal := True)>
Public Class Principal
Shared Sub Main()
Dim rolesArray As String() = {"managers", "executives"}
Try
' Set the principal to a new generic principal.
Thread.CurrentPrincipal = _
New GenericPrincipal(New GenericIdentity( _
"Bob", "Passport"), rolesArray)
Catch secureException As SecurityException
Console.WriteLine("{0}: Permission to set Principal " & _
"is denied.", secureException.GetType().Name)
End Try
Dim threadPrincipal As IPrincipal = Thread.CurrentPrincipal
Console.WriteLine( _
"Name: {0}" & vbCrLf & "IsAuthenticated:" & _
" {1}" & vbCrLf & "AuthenticationType: {2}", _
threadPrincipal.Identity.Name, _
threadPrincipal.Identity.IsAuthenticated, _
threadPrincipal.Identity.AuthenticationType)
End Sub
End Class
[C#]
using System;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using System.Threading;
// Request permission to set thread principal.
[assembly: SecurityPermissionAttribute(
SecurityAction.RequestOptional, ControlPrincipal = true)]
class Principal
{
static void Main()
{
string[] rolesArray = {"managers", "executives"};
try
{
// Set the principal to a new generic principal.
Thread.CurrentPrincipal =
new GenericPrincipal(new GenericIdentity(
"Bob", "Passport"), rolesArray);
}
catch(SecurityException secureException)
{
Console.WriteLine("{0}: Permission to set Principal " +
"is denied.", secureException.GetType().Name);
}
IPrincipal threadPrincipal = Thread.CurrentPrincipal;
Console.WriteLine("Name: {0}\nIsAuthenticated: {1}" +
"\nAuthenticationType: {2}",
threadPrincipal.Identity.Name,
threadPrincipal.Identity.IsAuthenticated,
threadPrincipal.Identity.AuthenticationType);
}
}
The following code example shows how to set and retrieve the principal of a thread.
[Visual Basic]
Option Explicit
Option Strict
Imports Microsoft.VisualBasic
Imports System
Imports System.Security
Imports System.Security.Permissions
Imports System.Security.Principal
Imports System.Threading
' Request permission to set thread principal.
<Assembly: SecurityPermissionAttribute( _
SecurityAction.RequestOptional, ControlPrincipal := True)>
Public Class Principal
Shared Sub Main()
Dim rolesArray As String() = {"managers", "executives"}
Try
' Set the principal to a new generic principal.
Thread.CurrentPrincipal = _
New GenericPrincipal(New GenericIdentity( _
"Bob", "Passport"), rolesArray)
Catch secureException As SecurityException
Console.WriteLine("{0}: Permission to set Principal " & _
"is denied.", secureException.GetType().Name)
End Try
Dim threadPrincipal As IPrincipal = Thread.CurrentPrincipal
Console.WriteLine( _
"Name: {0}" & vbCrLf & "IsAuthenticated:" & _
" {1}" & vbCrLf & "AuthenticationType: {2}", _
threadPrincipal.Identity.Name, _
threadPrincipal.Identity.IsAuthenticated, _
threadPrincipal.Identity.AuthenticationType)
End Sub
End Class
[C#]
using System;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
using System.Threading;
// Request permission to set thread principal.
[assembly: SecurityPermissionAttribute(
SecurityAction.RequestOptional, ControlPrincipal = true)]
class Principal
{
static void Main()
{
string[] rolesArray = {"managers", "executives"};
try
{
// Set the principal to a new generic principal.
Thread.CurrentPrincipal =
new GenericPrincipal(new GenericIdentity(
"Bob", "Passport"), rolesArray);
}
catch(SecurityException secureException)
{
Console.WriteLine("{0}: Permission to set Principal " +
"is denied.", secureException.GetType().Name);
}
IPrincipal threadPrincipal = Thread.CurrentPrincipal;
Console.WriteLine("Name: {0}\nIsAuthenticated: {1}" +
"\nAuthenticationType: {2}",
threadPrincipal.Identity.Name,
threadPrincipal.Identity.IsAuthenticated,
threadPrincipal.Identity.AuthenticationType);
}
}
#9
关键看
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("Bob", "Passport"), rolesArray);
这一句。
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("Bob", "Passport"), rolesArray);
这一句。
#10
不过你要改一下程序,用WindowsPrincipal才行。
#11
adminyao(程序*)的方法挺好用,谢谢啦
Miracle(新一代的开山怪)的方法好像和我的问题不太一样啊,我没看明白呀
最近这些天一直在忙项目,没有时间上CSDN,忽然来看看,有这么多朋友在帮助我,真的是很感动啊,在这里一并谢过啦
如果哪位兄弟有“不用net命令”的解决方法的话,请发CSDN的短信息给我,我会新开一个窗口,同样是一百分!
在这里先谢啦!!!
再次谢过以上的几位兄弟。
本贴结贴
Miracle(新一代的开山怪)的方法好像和我的问题不太一样啊,我没看明白呀
最近这些天一直在忙项目,没有时间上CSDN,忽然来看看,有这么多朋友在帮助我,真的是很感动啊,在这里一并谢过啦
如果哪位兄弟有“不用net命令”的解决方法的话,请发CSDN的短信息给我,我会新开一个窗口,同样是一百分!
在这里先谢啦!!!
再次谢过以上的几位兄弟。
本贴结贴