We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,874 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

getting mapped drives list

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

3
Contributors
3
Replies
3 Hours
Discussion Span
4 Years Ago
Last Updated
4
Views
anusumesh
Newbie Poster
15 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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

dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 144
Skill Endorsements: 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

anusumesh
Newbie Poster
15 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0644 seconds using 2.67MB