IIS does not create metabase nodes for you on access. If the node doesn't
exist, you need to create it first before setting/using any of its
properties. Also, you need to individually create intervening nodes instead
of all at once.
i.e. you want to set values on
"localhost/w3svc/1/root/vdir1/folder1/folder2/file.ext", and you have an
existing node at "localhost/w3svc/1/root/vdir1". You need to create
folder1, folder2, and file.ext nodes individually instead of creating
"/folder1/folder2/file.ext" at once in a creation call. IIS5 doesn't force
this, but IIS6 will. Why? Well, suppose you create
"/folder1/folder2/file.ext" as a IIsWebFile, and folder1 and folder2 are
autocreated -- can you tell me what the KeyType for /folder1 and /folder2
are supposed to be??
WebFile ADSI objects do not exist by default, so you'll need to first create
it using the path that you've been using in the code. Then, you can attempt
to access its inherited properties plus set overriding properties (for
example, AnonymousUserName property is likely INHERITED from the parent. As
soon as you set it, it forever overrides any parent properties for the node
until you delete it to re-engage value inheritance).
AuthFlags = 2 makes sure only Basic is checked.
AccessSSLFlags & 0xFFFFFFF7 will turn off "Require SSL".
--
//David
IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
//
[quoted text, click to view] "David Miller" <dmiller@crowechizek.com> wrote in message
news:0b7801c3c655$f8ec9580$a501280a@phx.gbl...
I should have been a bit more specific in my post. I'm
attempting to get this working using IIS 5.0 on a Win2k
machine. According to the documentation, I should be
able to use a IISWebFile ADSI object to get/set the
properties I need
(
http://msdn.microsoft.com/library/default.asp? url=/library/en-us/iissdk/iis/ref_prog_iaorefiwf.asp).
However, the following C# code fails:
DirectoryEntry objIIS = new DirectoryEntry
("IIS://localhost/W3SVC/1/ROOT/autobase/leadnote.asmx");
String user = (string) objIIS.Properties
["AnonymousUserName"].Value;
Here, autobase is a virtual directory and leadnote.asmx
is the file I'm interested in. This code will fail on an
exception that the path cannot be found. If I remove the
file and reference only the virtual directory, the code
works fine. I am certain that the file exists.
Any ideas on why this is not working?
Dave
[quoted text, click to view] >-----Original Message-----
>What are you asking? There is a way to do this with
ADSI, WMI and even some
>other means (like changing the metabase yourself). The
fact that you're
>suggesting those seems to imply that you know how to use
them, so do it. The
>"key" is the path to the file, in a web context, such as
this:
>
>W3SVC/1/Root/vdir/leadnote.asmx
>
>Use your favorite technology to set metabase properties
you need.
>
>Jerry
>
>"David Miller" <dmiller@crowechizek.com> wrote in message
>news:fb6842a.0312181440.1085c7c1@posting.google.com...
>> I currently have a manual process as a part of an
install that I'm
>> trying to automate. Is there any way to do the
following to an
>> individual FILE within a virtual directory through
ADSI, WMI, or some
>> other means (ie. Win32 API's)?
>>
>> a. Run Start-Programs-Administrative Tools-Internet
Services Manager
>> b. Double click the server name to expand the server
web sites.
>> c. Double click the Default web site to expand it
>> d. Double click the virtual directory folder to expand
it.
>> e. In the right pane, right click leadnote.asmx
>> f. Click the file security tab.
>> g. In the Anonymous access and authentication control
section, click
>> the edit button
>> h. Check basic authentication. Make sure all other
options are
>> unchecked.
>> i. Click the OK button.
>> j. In the secure communications section, click the
Edit button.
>> k. Uncheck Require Secure Channel.
>> l. Click OK.
>> m. Click OK.
>> n. Close Internet Services Manager.
>>
>> Any help (especially sample code) would be GREATLY
appreaciated!
>>
>> Dave
>
>
>.
>