Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > REPOST: Error Using WMI to Get List of Shared Folders on the Server

Reply
Thread Tools

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

 
 
lecnac
Guest
Posts: n/a
 
      04-24-2006
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.Username = "username";
ms.Options.Password = "password";
ms.Options.Authentication = Authentication.PacketPrivacy;
ms.Path = new ManagementPath("//server/root/CIMv2");

mc = new ManagementClass(ms, new ManagementPath("Win32_Share"), 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)" <(E-Mail Removed)> wrote
in message news:(E-Mail Removed)...
> 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="true"/> and give the app pool an account
> with network permissions.
>
> -- bruce (sqlwork.com)
>
> "lecnac" <(E-Mail Removed)> wrote in message
> news:%23gb5E%(E-Mail Removed)...
> > 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>
> > <authentication mode="Windows"/>
> > <identity impersonate="true"/>
> > </system.web>
> >
> >
> > .aspx.cs snippet (from Page_Load event)
> > using (System.Management.ManagementClass exportedShares = new
> > System.Management.ManagementClass("Win32_Share"))
> > {
> > System.Management.ManagementObjectCollection shares =
> > exportedShares.GetInstances();
> >
> > foreach (System.Management.ManagementObject 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.Management.ManagementObjectCollection shares

=
> > exportedShares.GetInstances();. The exception details are:
> > System.Management.ManagementException: 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).
> >
> >
> >

>
>




 
Reply With Quote
 
 
 
 
Jeff Dillon
Guest
Posts: n/a
 
      04-24-2006
#3 should work. Just run the site under a sufficient user account.

Why do you need impersonate?

Jeff

"lecnac" <(E-Mail Removed)> wrote in message
news:OBu1S4%(E-Mail Removed)...
> 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.Username = "username";
> ms.Options.Password = "password";
> ms.Options.Authentication = Authentication.PacketPrivacy;
> ms.Path = new ManagementPath("//server/root/CIMv2");
>
> mc = new ManagementClass(ms, new ManagementPath("Win32_Share"), 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)" <(E-Mail Removed)>
> wrote
> in message news:(E-Mail Removed)...
>> 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="true"/> and give the app pool an account
>> with network permissions.
>>
>> -- bruce (sqlwork.com)
>>
>> "lecnac" <(E-Mail Removed)> wrote in message
>> news:%23gb5E%(E-Mail Removed)...
>> > 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>
>> > <authentication mode="Windows"/>
>> > <identity impersonate="true"/>
>> > </system.web>
>> >
>> >
>> > .aspx.cs snippet (from Page_Load event)
>> > using (System.Management.ManagementClass exportedShares = new
>> > System.Management.ManagementClass("Win32_Share"))
>> > {
>> > System.Management.ManagementObjectCollection shares =
>> > exportedShares.GetInstances();
>> >
>> > foreach (System.Management.ManagementObject 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.Management.ManagementObjectCollection shares

> =
>> > exportedShares.GetInstances();. The exception details are:
>> > System.Management.ManagementException: 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).
>> >
>> >
>> >

>>
>>

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Error Using WMI to Get List of Shared Folders on the Server lecnac ASP .Net 0 04-24-2006 09:01 PM
Re: Error Using WMI to Get List of Shared Folders on the Server lecnac ASP .Net 0 04-24-2006 08:21 PM
Error Using WMI to Get List of Shared Folders on the Server lecnac ASP .Net 1 04-21-2006 08:36 PM
Accessing Shared Folders on a computer in another domain using UNC Baron ASP .Net 3 04-29-2005 02:45 PM
built with --enable-shared but get error: libpython2.3.so.1.0: can't open shared object file Douglass Turner Python 2 09-04-2003 01:56 PM



Advertisments