2012-01-13 3 views
2

사용자가 브라우저 플러그인이 포함 된 IIS aspx 페이지를 통해 터미널 서버에서 로컬 스캐너를 사용하도록 허용하려고합니다. 플러그인은 파일을 스캔하고 파일을 서버에 업로드하는 aspx 페이지로 데이터를 전달할 수 있습니다.터미널 서비스 사용자의 문서 폴더 찾기

HttpContext.Current.User.Identity.Name을 사용하여 원격 사용자의 이름이 포함 된 문자열을 가져옵니다. 터미널 서버에서 사용자의 문서 폴더를 찾으려면 어떻게합니까?

답변

0

약간의 진전이있었습니다. 여기

$user = Get-WmiObject Win32_UserAccount | Where-Object { $_.Name -eq 'known_username' } 
cd 'HKLM:\software\Microsoft\Windows NT\CurrentVersion\ProfileList' 
$key = Get-Item $user.SID 
$saveLocation = $key.GetValue("ProfileImagePath") 

는 C# 버전 것 : 여기 PowerShell을 사용 알려진 이름에 대한 경로를 찾을 수있는 방법입니다

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#을 내 모국어가 아니다; 덜 둔한이 방법을 수행하는 방법이있을 것입니다. 하지만 일을합니다.