English 中文(简体)
Findron 服务用户文件夹
原标题:Find Terminal Services user s document folder

I m试图允许用户使用其当地扫描仪,通过载有浏览器粉面的IIS as页,使用终端服务器。 粉碎机可以扫描文档,并将数据传送到一个星页上,把文件上载到服务器。

I m 采用HttpContext。 现任。 用户。 姓名,包括载有遥远用户名称的画面。 如何在终端服务器上找到用户文件夹?

最佳回答

取得了一定的进展。 这里为使用Powerhell的已知用户名找到一条途径:

$user = Get-WmiObject Win32_UserAccount | Where-Object { $_.Name -eq  known_username  }
cd  HKLM:softwareMicrosoftWindows NTCurrentVersionProfileList 
$key = Get-Item $user.SID
$saveLocation = $key.GetValue("ProfileImagePath")

C#版本:

string loginName = HttpContext.Current.User.Identity.Name;
Regex r = new Regex(@"w+[\]");
string userName = r.Replace(loginName, "");
throw new System.ArgumentException("Debug:  " + HttpContext.Current.User.Identity.IsAuthenticated.ToString() +" ", "userName");
SelectQuery sQuery = new SelectQuery("Win32_UserAccount", "name= " + userName + " ");
ManagementObjectSearcher mSearcher = new ManagementObjectSearcher(sQuery);
string sid = "";
foreach (ManagementObject mObject in mSearcher.Get()) 
{
    sid = mObject["SID"].ToString();
    break; //mSearcher.Get() is not indexable. Behold the hackyness!
}
string saveLocation = Microsoft.Win32.Registry.GetValue(
    "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\" + sid,
    "ProfileImagePath", null).ToString();

C#不是我的母语;可能有一些方法可以做到这一点,但这种方式不太unt。 但does工作。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签