473,655 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error Using WMI to Get List of Shared Folders on the Server

Here's some details:

Server and workstation both in the same workgroup
Logged into server as local Administrator
Logged into workstation as a local user that is only in the Users group
The local user on the workstation is also defined with same name and
password on the server (and only in the Users group on the server)
Server is Windows Server 2003 running IIS 6.0
Workstation is Windows XP Professional
ASP.NET 2.0 (C#) web site
Web.config snippet
<system.web>
<authenticati on mode="Windows"/>
<identity impersonate="tr ue"/>
</system.web>
..aspx.cs snippet (from Page_Load event)
using (System.Managem ent.ManagementC lass exportedShares = new
System.Manageme nt.ManagementCl ass("Win32_Shar e"))
{
System.Manageme nt.ManagementOb jectCollection shares =
exportedShares. GetInstances();

foreach (System.Managem ent.ManagementO bject share in shares)
{
// Get shared folder information, for example
Response.Write( "Name: " + share["Name"].ToString());
}
}
Open IE and navigate to the web site on the server (using
http://servername/website). I get an access denied error. The exception is
thrown on the line: System.Manageme nt.ManagementOb jectCollection shares =
exportedShares. GetInstances(); . The exception details are:
System.Manageme nt.ManagementEx ception: Access denied

What I'm trying to do is list all the shared folders on the server on a
page. However, when I run this application from a different computer, I get
the access denied error.

** How can I get a list of shared folders on the server no matter what
computer is accessing the ASP.NET application?
** What do I need to do differently to get the above code and scenario to
work?

** Is there a better way of doing this than WMI? If so, what?
P.S., On the server, I tried give the local user full WMI permissions
through Computer Management, and it didn't work (nothing changed; I still
got the access denied error).

Apr 21 '06 #1
1 2889
this setup won't work. the web service is running with a secondary credital,
so it can not access a network resource (one hop rule). you have three
options

1) set the web site to basic authenication
2) switch to activce directory and kerberos.
3) remove <identity impersonate="tr ue"/> and give the app pool an account
with network permissions.

-- bruce (sqlwork.com)

"lecnac" <no****@company .com> wrote in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
Here's some details:

Server and workstation both in the same workgroup
Logged into server as local Administrator
Logged into workstation as a local user that is only in the Users group
The local user on the workstation is also defined with same name and
password on the server (and only in the Users group on the server)
Server is Windows Server 2003 running IIS 6.0
Workstation is Windows XP Professional
ASP.NET 2.0 (C#) web site
Web.config snippet
<system.web>
<authenticati on mode="Windows"/>
<identity impersonate="tr ue"/>
</system.web>
.aspx.cs snippet (from Page_Load event)
using (System.Managem ent.ManagementC lass exportedShares = new
System.Manageme nt.ManagementCl ass("Win32_Shar e"))
{
System.Manageme nt.ManagementOb jectCollection shares =
exportedShares. GetInstances();

foreach (System.Managem ent.ManagementO bject share in shares)
{
// Get shared folder information, for example
Response.Write( "Name: " + share["Name"].ToString());
}
}
Open IE and navigate to the web site on the server (using
http://servername/website). I get an access denied error. The exception
is
thrown on the line: System.Manageme nt.ManagementOb jectCollection shares =
exportedShares. GetInstances(); . The exception details are:
System.Manageme nt.ManagementEx ception: Access denied

What I'm trying to do is list all the shared folders on the server on a
page. However, when I run this application from a different computer, I
get
the access denied error.

** How can I get a list of shared folders on the server no matter what
computer is accessing the ASP.NET application?
** What do I need to do differently to get the above code and scenario to
work?

** Is there a better way of doing this than WMI? If so, what?
P.S., On the server, I tried give the local user full WMI permissions
through Computer Management, and it didn't work (nothing changed; I still
got the access denied error).

Apr 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3035
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
6
4739
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
8
9449
by: Razak | last post by:
Hi, I have a class which basically do Impersonation in my web application. From MS KB sample:- ++++++++++++++++++++code starts Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
2
6929
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it, I get the runtime error noted at the end of this message. If I re-compile (without any changes) and re-run, then my project will run OK. This behavior is very consistent. Another words, the only way I can run an ASP.NET application is if I...
5
1967
by: Dan Lorenz | last post by:
When trying to use the function CreateDirectory on my local machine everything works fine but when I upload the page to my webhost I get an issue that it can't find path on D:\, though D:\ is what my website is found on. This is an H-SPHERE web cluster host. From my research I found that this issue is due to ASPNET account not having read previdgeles on the root of the drive. My question is what is the correct approach to solve this...
1
2421
by: lecnac | last post by:
Here's some details: Server and workstation both in the same workgroup Logged into server as local Administrator Logged into workstation as a local user that is only in the Users group The local user on the workstation is also defined with same name and password on the server (and only in the Users group on the server) Server is Windows Server 2003 running IIS 6.0 Workstation is Windows XP Professional ASP.NET 2.0 (C#) web site
1
3693
by: lecnac | last post by:
Sorry for the repost. I must have done something wrong when I tried to post my reply (I can't seem to find it). Anyway, I'd really appreciate any help that anyone could provide. My issue is quickly becoming more and more urgent. I've tried the code below using the server's local Administrator user name and password. This gets me past the Access denied error but gives me a User
4
5630
by: Dave | last post by:
The below code is what I'm using to upload JPG's to a Shared folder on my web server. The folder \\GLSDBS03\Entry$ is outside my Web folder. When using FileUpload, and trying to save the JPG, I get a "Failed to map the path '/GLSDBS03/Entry$'" error. I'm open to suggestions or a better idea. Thanks *********************************************
1
15041
by: JordanRieger | last post by:
Here is a nasty issue that has been giving me grief for the last couple days. This requires good knowledge of IIS, MSXML, and Windows/NTFS permissions. We have an existing ASP (VBScript) app hosted on IIS 6.0 (W2K3). We need to restrict access to specific users within our company network. To reduce development effort I figured the easiest solution was to enable Integrated Windows Authentication. However once I enable IWA and disable...
0
8296
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,...
0
8710
jinu1996
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...
0
7310
agi2029
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
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();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.