Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Entertainment » microsoft.public.windowsmedia.sdk
Thread: Using WMPLib in IIS

HTVi
TV Discussion Newsgroups

Using WMPLib in IIS
John 10/23/2008 6:14:08 PM
I've created a simple web application that has the following code:

WMPLib.WindowsMediaPlayer player = new
WMPLib.WindowsMediaPlayerClass();
WMPLib.IWMPPlaylist plist;

plist = player.mediaCollection.getByAttribute("MediaType", "audio");
Response.Write(plist.count);

When this runs through the ASP.Net Deployment Server, this works fine; the
correct number of songs are printed. However, if I run this via IIS instead,
it reports that there are 0 songs.

What am I missing? Is there a better methodology to access the windows
media library opposed to going through WMPLib.dll in ASP.Net?

Thanks!

Re: Using WMPLib in IIS
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 10/23/2008 6:46:53 PM
From: "John"

[Quoted Text]
> When this runs through the ASP.Net Deployment Server,
> this works fine; the correct number of songs are printed.
> However, if I run this via IIS instead, it reports that
> there are 0 songs.
>
> What am I missing? Is there a better methodology to
> access the windows media library opposed to going through
> WMPLib.dll in ASP.Net?

The MediaLibrary is a per-user resource. If you run the code
inside VS, it will run as the current user and access the
current user's library. If you run it inside IIS, it will
run in the context of the SYSTEM account (or whatever
account the IIS service is running under) and access that
account's library, which doesn't exist.

WMP is not designed as a server-side component. If you want
it to access a given user's library, you can *try*
impersonating that user on the thread that creates the WMP
instance. User imporsonation is a security topic, not a
WindowsMedia one. See
System.Security.Principal.WindowsImpersonationContext and
advapi32.dll!ImpersonateLoggedOnUser().

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Re: Using WMPLib in IIS
John 10/23/2008 7:04:00 PM
I thought the same thing, Alessandro, and so I tried the following things:

* added Identity Impersonate = true (didn't work)
* Set the application pool to run as a specific user, me (didn't work)
* Impersonated the current user through code in the same method I use WMP
(didn't work)

I realize the library wasn't intended to be used this way, but I would have
to think there has to be an API that would allow me to do this (get what
songs are in a library), from what's available with media connect, etc,
especially since the code works outside of IIS. I've been told this works on
other servers such as cassini, just not IIS

"Alessandro Angeli" wrote:

[Quoted Text]
> From: "John"
>
> > When this runs through the ASP.Net Deployment Server,
> > this works fine; the correct number of songs are printed.
> > However, if I run this via IIS instead, it reports that
> > there are 0 songs.
> >
> > What am I missing? Is there a better methodology to
> > access the windows media library opposed to going through
> > WMPLib.dll in ASP.Net?
>
> The MediaLibrary is a per-user resource. If you run the code
> inside VS, it will run as the current user and access the
> current user's library. If you run it inside IIS, it will
> run in the context of the SYSTEM account (or whatever
> account the IIS service is running under) and access that
> account's library, which doesn't exist.
>
> WMP is not designed as a server-side component. If you want
> it to access a given user's library, you can *try*
> impersonating that user on the thread that creates the WMP
> instance. User imporsonation is a security topic, not a
> WindowsMedia one. See
> System.Security.Principal.WindowsImpersonationContext and
> advapi32.dll!ImpersonateLoggedOnUser().
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> // http://www.riseoftheants.com/mmx/faq.htm
>
>
>
Re: Using WMPLib in IIS
"Alessandro Angeli" <nobody[ at ]nowhere.in.the.net> 10/23/2008 8:40:06 PM
From: "John"

[Quoted Text]
> I realize the library wasn't intended to be used this
> way, but I would have to think there has to be an API
> that would allow me to do this (get what songs are in a
> library), from what's available with media connect, etc,
> especially since the code works outside of IIS. I've
> been told this works on other servers such as cassini,
> just not IIS

Since WMP is designed to run interactively, maybe, in
addition to requiring to run in the context of the user that
owns the library, it also requires to run in a desktop,
which most services, including IIS, don't have (but a few
others attach themselves to the interactive desktop if
allowed to do so). Do not mistake service for server: I
never used Microsoft's Cassini web server, but it may be
just a desktop application and not a system service.



--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


Re: Using WMPLib in IIS
John 10/24/2008 11:39:01 AM
Thanks for your input Alessandro!

I think I'm going to abandon the WMP approach and just scan through the
directories looking for files myself (reading in their tag information)

Thanks!

"Alessandro Angeli" wrote:

[Quoted Text]
> From: "John"
>
> > I realize the library wasn't intended to be used this
> > way, but I would have to think there has to be an API
> > that would allow me to do this (get what songs are in a
> > library), from what's available with media connect, etc,
> > especially since the code works outside of IIS. I've
> > been told this works on other servers such as cassini,
> > just not IIS
>
> Since WMP is designed to run interactively, maybe, in
> addition to requiring to run in the context of the user that
> owns the library, it also requires to run in a desktop,
> which most services, including IIS, don't have (but a few
> others attach themselves to the interactive desktop if
> allowed to do so). Do not mistake service for server: I
> never used Microsoft's Cassini web server, but it may be
> just a desktop application and not a system service.
>
>
>
> --
> // Alessandro Angeli
> // MVP :: DirectShow / MediaFoundation
> // mvpnews at riseoftheants dot com
> // http://www.riseoftheants.com/mmx/faq.htm
>
>
>
Re: Using WMPLib in IIS
"Chris P." <msdn[ at ]chrisnet.net> 10/24/2008 4:34:30 PM
On Fri, 24 Oct 2008 04:39:01 -0700, John wrote:

[Quoted Text]
> Thanks for your input Alessandro!
>
> I think I'm going to abandon the WMP approach and just scan through the
> directories looking for files myself (reading in their tag information)

There's also a way to get the information in XML form by issuing web
queries to the UPnP Media server that is part of WMP11. I had played with
this years ago when it was the seperate Windows Media Connect.
Unfortunately I was having a hard time finding good documentation on this
when I did a few searches yesterday as the WMC docs are no more. It was
also very simple to retrieve a http encapsulated mp3/wma stream through
this.

--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen