1,105,169 Community Members

getting mapped drives list

Member Avatar
anusumesh
Newbie Poster
14 posts since Nov 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
dickersonka
Veteran Poster
1,173 posts since Aug 2008
Reputation Points: 104 [?]
Q&As Helped to Solve: 145 [?]
Skill Endorsements: 0 [?]
 
0
 

are you sure the user that you are impersonating has permissions to the mapped drives?

try logging in as that user and seeing if the mapped drives exist

Member Avatar
anusumesh
Newbie Poster
14 posts since Nov 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

impersonating user is member of administartors group.

And also when i tried deploying that application in IIS, its not giving dmapped drives in either case(means order of calling function does not matter in case of IIS)

Thanks
Anu

Member Avatar
LizR
Posting Virtuoso
1,735 posts since Aug 2008
Reputation Points: 171 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 4 [?]
 
0
 

Um, if its not running directly in the users session then it wont have any mapped drives - as its not the same.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article