473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

getting mapped drives

AnuSumesh
Hi all,

I am writing one application using c# in which firstly I m getting impersonating the user and then i want to retrieve mapped Drives.

But issue is when I am calling method in following sequence:
1. create object of class
2. call mappeddrives() method
3. call impersonate method

then its working fine.
But if i m calling impersonate method before calling mappeddrives() then its not giving me list of mapped drives.

my code for getting mapped drives is :
Expand|Select|Wrap|Line Numbers
  1. public string MappedDrives()
  2.         {
  3.             string drives = "";
  4.             DriveInfo[] allDrives = DriveInfo.GetDrives();
  5.  
  6.             foreach (DriveInfo dirInfo in allDrives)
  7.             {
  8.                 if (dirInfo.DriveType.ToString() == "Network")
  9.                     drives += dirInfo.Name+"?";                           
  10.             }
  11.            return drives;
  12.         }
  13.  
Can anyone tell me the reason behind this?

Thanks,
Anu
Nov 24 '08 #1
14 5345
Plater
7,872 Expert 4TB
Impersonating a user does not run their login script, where mapped drives would be created?
Just a guess
Nov 24 '08 #2
im not creating mapped drives. just retrieving the list of mapped drived.
And one more point - when i deployed my application in IIS, its not gibving me mapped drive list in either case.

Thanks,
Anu
Nov 24 '08 #3
Plater
7,872 Expert 4TB
Mapped drives are mapped when a user logs on. If the user has not logged on, the drive is not mapped.
Nov 24 '08 #4
sorry i did not understand.
u m running my application in visual studio before calling impersonate method then its giving me all mapped drives.
Nov 24 '08 #5
Plater
7,872 Expert 4TB
Before impersonating, it is running as the logged on user. That user's drives have been mapped since the logon script was executed
Nov 25 '08 #6
but logged on user and impersonating user are same
Nov 25 '08 #7
Plater
7,872 Expert 4TB
@AnuSumesh
Ok, now we're getting somewhere (although that throws my idea out the window)
So if you are logged on as userA, you can see the drives, then you tell your program to run impersonating userA, and you cannot see the drives?
Now I really don't know what to suggest.

Have you tried getting the mapped drives with a WMI search?
Expand|Select|Wrap|Line Numbers
  1.  
  2. ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_MappedLogicalDisk"); 
  3.  
  4.  
Nov 25 '08 #8
No.
can u give me link how to use wmi for getting mapped drives?

Anu
Nov 25 '08 #9
Plater
7,872 Expert 4TB
I recomend the WMICodeCreator tool. Very usefull and it creates sample code for you
Nov 25 '08 #10
i have tried with this tool also. result is same. means giving mapped drives before impersonation only.
Nov 25 '08 #11
I have solved by using "Win32_MappedLogicalDisk" its working.
Thanks a lot.
But i have to try same via IIS also b'coz viz IIS nothing was working.

Anu
Nov 25 '08 #12
Can you Please help me in writing code in C# for supporting Double Byte Character support for the same application?

Thanks
Anu
Nov 25 '08 #13
Plater
7,872 Expert 4TB
@AnuSumesh
That is really a different question, but I imagine it has something to do with the declared locale and you can probably use the various UTF converters found on System.Text.Encoder
Nov 25 '08 #14
Thanks for reply. I am using the same system.text.encoding but please guide me how i can test for the same on my window xp machine (For japanese)?
Nov 25 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Hal Vaughan | last post by:
I've seen install programs that search a hard drive for previous instances of a program, or to find installs of other needed programs. I need to search a hard drive for any installations of...
0
by: Ricky | last post by:
My question: If I have a mapped driver letter g: that referes to \\servername\d\foldername How do I get java to convert it from g: to the real path so I can use it? I have a script that...
2
by: giloosh99 | last post by:
Hello, Im grabbing tables via VB code using visual foxpro ODBC drives. The tables directory is in a mapped network drive. The code works fine and does the job, however if the computer is idle for...
3
by: Bonj | last post by:
I have a service which is a Windows Service, but it is running under a User account - I enter my own credentials on installing. It can access network files by specifying the full UNC path, i.e....
5
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a...
2
by: Ben | last post by:
Hi, Thanks for reading this post... I am trying to get the computer/server names from the mapped drives on the Clients PC when they select a file from the upload "browse" button. When the user...
5
by: Marc | last post by:
I am trying to run a web service that has pre-compiled dll's that reference dll's that are on a mapped drive. The web service can not load because it does not see that mapped drive and returns an...
0
by: rmckbrown | last post by:
Using .Net FW 1.1 and VB.net I am calling system.io.directory.getlogicaldrives from a windows service; however, only the local drives are returned, and not my mapped drives. When I execute the...
1
by: tanya.wang | last post by:
I want to access files from a remote server so I mapped it in my server under z:\ for \\myserver\web\mysite\images\ I added this UNC path to my IIS virtual directory and name it as "upload" but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.