473,854 Members | 1,672 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.

Thanks for the thoughts Bruce. However, we can't do #1 (we must use
Integrated Windows Authentication) . And, can't do #2 (the server will be,
for the most part, a stand-alone server just for our intranet application).
And, we need impersonation = "true" in #3.

So, any other thoughts/ideas?

Anyone?
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
credentials cannot be used for local connections error.

ManagementScope ms;
ManagementClass mc;

ms = new ManagementScope ();
ms.Options.User name = "username";
ms.Options.Pass word = "password";
ms.Options.Auth entication = Authentication. PacketPrivacy;
ms.Path = new ManagementPath( "//server/root/CIMv2");

mc = new ManagementClass (ms, new ManagementPath( "Win32_Shar e"), null);
Maybe another thought... Should I not use WMI to try to get a list of
shared folders on the server? Should I use something else? If so, what?

"bruce barker (sqlwork.com)" <b_************ *************@s qlwork.com> wrote
in message news:eU******** ******@TK2MSFTN GP04.phx.gbl...
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 24 '06 #1
1 2056
#3 should work. Just run the site under a sufficient user account.

Why do you need impersonate?

Jeff

"lecnac" <no****@company .com> wrote in message
news:OB******** ********@TK2MSF TNGP02.phx.gbl. ..
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.

Thanks for the thoughts Bruce. However, we can't do #1 (we must use
Integrated Windows Authentication) . And, can't do #2 (the server will be,
for the most part, a stand-alone server just for our intranet
application).
And, we need impersonation = "true" in #3.

So, any other thoughts/ideas?

Anyone?
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
credentials cannot be used for local connections error.

ManagementScope ms;
ManagementClass mc;

ms = new ManagementScope ();
ms.Options.User name = "username";
ms.Options.Pass word = "password";
ms.Options.Auth entication = Authentication. PacketPrivacy;
ms.Path = new ManagementPath( "//server/root/CIMv2");

mc = new ManagementClass (ms, new ManagementPath( "Win32_Shar e"), null);
Maybe another thought... Should I not use WMI to try to get a list of
shared folders on the server? Should I use something else? If so, what?

"bruce barker (sqlwork.com)" <b_************ *************@s qlwork.com>
wrote
in message news:eU******** ******@TK2MSFTN GP04.phx.gbl...
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 24 '06 #2

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

Similar topics

0
3050
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)
1
3041
by: Miller | last post by:
Hi everybody! These messages have been found in the System log of the Event Viewer application. These error messages have been generated after each logon attempt. Although dial-in client have been connected to the host pc, But client was unable to open the target host, and its failure attempts have been recorded in the System log. It seems that something must be configured on host, which gives client more to provide in the authentication...
6
4770
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
0
2063
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows the available information based on the second combo box selection. But if I change my mind and select a different item in the second box, after the third box has been populated, the third box still retains the information that was previously...
8
9483
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
6942
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...
1
2913
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
3709
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
1
15087
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
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9750
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
10364
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7909
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
7077
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
5738
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
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4150
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.