1.11M Members

getting mapped drives list

 
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

 
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

 
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

 
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 six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article