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 : -
public string MappedDrives()
-
{
-
string drives = "";
-
DriveInfo[] allDrives = DriveInfo.GetDrives();
-
-
foreach (DriveInfo dirInfo in allDrives)
-
{
-
if (dirInfo.DriveType.ToString() == "Network")
-
drives += dirInfo.Name+"?";
-
}
-
return drives;
-
}
-
Can anyone tell me the reason behind this?
Thanks,
Anu
14 5403 Plater 7,872
Recognized Expert Expert
Impersonating a user does not run their login script, where mapped drives would be created?
Just a guess
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
Plater 7,872
Recognized Expert Expert
Mapped drives are mapped when a user logs on. If the user has not logged on, the drive is not mapped.
sorry i did not understand.
u m running my application in visual studio before calling impersonate method then its giving me all mapped drives.
Plater 7,872
Recognized Expert Expert
Before impersonating, it is running as the logged on user. That user's drives have been mapped since the logon script was executed
but logged on user and impersonating user are same
Plater 7,872
Recognized Expert Expert @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? -
-
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_MappedLogicalDisk");
-
-
No.
can u give me link how to use wmi for getting mapped drives?
Anu
Plater 7,872
Recognized Expert Expert
I recomend the WMICodeCreator tool. Very usefull and it creates sample code for you
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 OpenOffice. I know
in *nix I can start by using "/" as the file name and doing a recursive
listing of the file system from there. (Yes -- I know about permissions to
read directories -- that's another issue I've already solved.)
How do I find the...
|
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 allows someone to locate a file on the server,
but most will use there mapped drives as they know nothing better.
|
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 a while the
network drive apears to have a red X on the icon and the drive becomes
disconnected. this seems to effect the VB code from grabbing the
tables. I get an error saying the specific table cannot be found. If i
manually open the mapped...
|
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.
\\server\share, but it can't use mapped drive letters.
Is there anyway I can modify it so that it can?
Thanks
|
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 seperate files server.
we have mapped the fodler to a different folder and need to allow the EXE to
process on the mapped drive. When I trigger the EXE via web service the EXE
get the permission of the launching user (mean ASP.NET user) resulting a...
| |
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
clicks on the "Browse" button on the "<input type="File"... control and
selects a file located in one of many possible mapped drives. I want
to save the location of the file as a path as you would see when
mapping a drive. For instance,...
|
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 error of "Can not file
specified module". Mapped drive is added to path.
Thanks,
Marc
|
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 call from a regular Windows application, all of the drives are returned. Any thoughts on why the mapped drives are not returned when the call is made from a windows service?
The windows service is running under a domain user account with admin...
|
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 still cannot use any FSO to read it. Here is my code:
<%
Dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |