|
Hi,
I tried to used your code in my web applcation with the following codes to map network drives but I got an error message.
try<br />
{<br />
oNetDrive.LocalDrive = "T";<br />
oNetDrive.ShareName = ConfigurationSettings.AppSettings["FileLocation"];<br />
oNetDrive.MapDrive("admin","123"); <br />
Response.Write("Mapped");<br />
}<br />
catch (Exception errs)<br />
{<br />
Response.Write(errs.Message);<br />
}
Error Message :A specified logon session does not exist. It may already have been terminated
Thanks
Dabuskol
|
|
|
|
|
This is rather complex... you are getting the error message because the application is isolated as such, meaning because of the security on the .net web server your web application does not have the security rights to allow you to map a network drive. I would suggest you modify the assembly / user access rights on your web server under the “Control Panel\Administrative Tools\Microsoft .NET Framework x.x Configuration” to allow the assembly full access. If you continue to have issues, notify me and ill try and hunt down another solution.
------------------------------------------------------------------------------------
aejw (http://www.aejw.com/)
|
|
|
|
|
I still get the same problem. This is the scenario.
My web applcation is in web server1 with .net installation and everything. Then My program will connect to server 2 with (W2K3 OS, no .net installation, just a plain server with files) then download/insert files on it. In order for the program to get the files it needs to connect to server 2 though I used a username that has administrator priveledge still I am getting the same message.
On the other side, If I run your windows applcation using the same parameters as above I was able to connect to server2 from server1. It means the user access has the right to access server 2. Where is the problem, is it in my web app? I did follow your instrustions in README and everything but with no Luck.
Sorry to disturb you but everything on my application is working except this part.
Dabuskol
|
|
|
|
|
No its does not sounds like the application / code, this will be rather hard to work out... it sounds like its a privileges problem. For example, if one machine is in a domain and the other is not (or different domain), you will need to include the domain on the front of username, for example. "DOMAIN\username". Also make sure the username does have access to the share... etc etc.
----------------------------
aejw.com
|
|
|
|
|
I created a similar program in windows .net and it works fine. But like you said all I need is to add the DOMAIN before the username of my server2 which luckly worked. I did tried it before but for no reason it didn't work.
Thanks for your help and Ideas my web application is working fine.
Server1/admin
Great
Dabuskol
Dabsukol
|
|
|
|
|
Thank-you for putting this wrapper out here.
Very grateful. Saved me a bit of time.
-smiles- Just another perl hacker shifting gears.
|
|
|
|
|
Is there any way to actually delete the drive? The unmapped function just disconnects it. Is there a way to make it actually delete the drive so it doesn't show up in My Computer?
Thanks in advance
|
|
|
|
|
As long as it a maped network drive and you ensure Persistant is set to false
----------------------------
aejw.com
-- modified at 1:00 Monday 1st May, 2006
|
|
|
|
|
The shared location, Ex : \\hostname\folder1, is not getting mapped using windows service in Windows Server 2003.
I am using following code:
NetworkDrive networkDrive = new NetworkDrive ();
networkDrive.Force = true;
networkDrive.Persistent = false;
networkDrive.LocalDrive = "V:";
networkDrive.PromptForCredentials = false;
networkDrive.ShareName = strSharedLocation;
networkDrive.SaveCredentials = false;
networkDrive.MapDrive();
Please help me...
Thanks,
Samir
|
|
|
|
|
I have had some feedback about Windows 2003 and all reports apart from yours appears well... It could be your policy / security settings on the 2003 machine. Also check that V: is not already mapped and you are passing all the values correctly...
----------------------------
aejw.com
|
|
|
|
|
My application is windows service. On start of the service it tries to map the network location using your code. Due to security difference in Win2k3 servers I had to do this coz the mapped location using windows explorer will not be accessable in my service session.
So wat happens if I try to map the drive V, which is already mapped using windows explorer, using your code ? Coz I have to map the location in my service session, the other one is not accessable.
Thanks,
-Samir
-- modified at 14:16 Wednesday 17th May, 2006
|
|
|
|
|
I have the same issue except that I am calling it from a Scheduled Task and it can't get the drive to be mapped.
Any clue?
My code is parctically the same as his code.
Thanks,
Nic.
|
|
|
|
|
I would pass the username and password via the credentials options.
----------------------------
aejw.com
|
|
|
|
|
working sample (windows service on win2003):
try{
NetworkDrive drive = new NetworkDrive();
drive.Force = true;
// drive.LocalDrive = ... <- not needed
drive.Persistent = true;
drive.SaveCredentials = true;
drive.ShareName = SourceDir;
drive.MapDrive("User", "Pass");
....
asa
|
|
|
|
|
Hi..
FOL thanks for posting this code...its really useful...
I am facing problem. I have included this class in my windows service project.On startup I am mapping a shared location on the machine. It works differently on server operation system. I am not able to map drive in my service in Windows 2000 server.
How different it is on Windows 2000 server ??
regards,
Samir
|
|
|
|
|
I have not had much feedback about Windows 2000, it should have no issues... Maybe Windows is not allowing you to map a drive with the service because its using the SYSTEM account when executed as a service...
----------------------------
aejw.com
|
|
|
|
|
I am having the same issue too. The project can establish the mapping on Windows Server 2003, but not on 2000. Both servers are using Active Directory ( don't know if that has an effect ). Does anyone have any idea?
Best Regards,
ron
|
|
|
|
|
is there a way to use oNetDrive.ShareName to get a list of the drives and their paths?
|
|
|
|
|
I use WMI to get a list of shares from a given
machine. Although you can always use a wrapper
for Shell.Application if you don't have local admin.
You can also use WMI to get a list of drives.
"Select size,freespace from Win32_LogicalDisk where name = '" + DriveL + "'
When you do the share query you need to make sure you don't pull in Administrative shares.. Here is the WMI query for that..
"Select name,path from Win32_Share where type != '2147483648' and type != '2147483651'"
Please, keep in mind that if you use the Shell.Application method, that you do not have the ability to see any hidden or administrative shares. With WMI you can see them, if you need to.
|
|
|
|
|
Is it oke to use this code.
As I read in the license and i need your permissions i see.
But i cann't mail you?.
All i want to do is map 4 drives on a custommer who doesn't allow net use or vbscript.
jipijie i'm on VB
jipijee i'm on C
|
|
|
|
|
Hello and sorry about the very slow reply, yes it can be used... An updated version is on my site www.aejw.com - which has an updated and very lax EULA. I will update code project before long...
----------------------------
aejw.com
|
|
|
|
|
help.
i use Asp.net to implement map network drive, but can't complete.
Arne
-- modified at 23:41 Tuesday 13th December, 2005
|
|
|
|
|
Hi,
what difference you expect here by using p/ Invoke when..
Map Drives are any way session bound
Map drives are unstable/ disconnect as session ends
Map dirves connection depends on various other factors like net work connectivity etc.
So if any of these problems cannot be solved with p/Invoke, why don't you just use the dos command to map the network drive via your application and aslo to delete it.
Simply writting a simple class to simulate DOS prompt will do this, doesn't it?
L.W.C. Nirosh,
Tech Lead,
TextCENTRIC Technology,
Colombo,
Sri Lanka
|
|
|
|
|
wa??? I have no idea what your on about, but never mind... Try getting feedback / error messages from a command prompt, lol...
----------------------------
aejw.com
|
|
|
|
|
Sorry for the late reply..
But mate do you wanna code to do it??
Just say yes.. I will pass it.
L.W.C. Nirosh,
Colombo,
Sri Lanka.
|
|
|
|