Share via


VirtualDirectoryDefaults.LogonMethod Property

Definition

Gets or sets the authentication method that is used by default for all virtual directories under the current context.

public:
 property Microsoft::Web::Administration::AuthenticationLogonMethod LogonMethod { Microsoft::Web::Administration::AuthenticationLogonMethod get(); void set(Microsoft::Web::Administration::AuthenticationLogonMethod value); };
public Microsoft.Web.Administration.AuthenticationLogonMethod LogonMethod { get; set; }
member this.LogonMethod : Microsoft.Web.Administration.AuthenticationLogonMethod with get, set
Public Property LogonMethod As AuthenticationLogonMethod

Property Value

One of the AuthenticationLogonMethod values. The default is ClearText.

Examples

The following example creates a new application that has explicitly set virtual directory defaults and then creates two new virtual directories. The virtual directory defaults are applied to the newly created directories when you update the configuration system by calling the CommitChanges method.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;

namespace AdministrationSnippets
{
    public class AdministrationApplicationVirtualDirectoryDefaults
    {

// Creates a new application, sets the virtual directory  
// defaults, creates two new virtual directories, and then  
// displays the new virtual directory values.
public void SetVirtualDirectoryDefaults()
{
    ServerManager manager = new ServerManager();
    Site defaultSite = manager.Sites["Default Web Site"];

    // Set up the defaults for the default application of the 
    // default Web site.
    Application app = defaultSite.Applications.Add(
        "/JohnDoe", @"C:\inetpub\wwwroot\john");

    app.VirtualDirectoryDefaults.LogonMethod = 
        AuthenticationLogonMethod.ClearText;
    app.VirtualDirectoryDefaults.UserName = @"NorthWest\JohnDoe";
    app.VirtualDirectoryDefaults.Password = @"kB56^j83!T";

    // Add two virtual directories.
    app.VirtualDirectories.Add(
        "/blogs" , @"\\FileServer\c$\blog_content\");
    app.VirtualDirectories.Add(
        "/photos", @"\\FileServer\c$\photo_content\");
    manager.CommitChanges();

    // Read the updated configuration.
    app = defaultSite.Applications["/JohnDoe"];

    foreach (VirtualDirectory vdir in app.VirtualDirectories)
    {
        Console.WriteLine("Virtual Directory Found: {0}", vdir.Path);
        Console.WriteLine("  |-Logon Method : {0}", vdir.LogonMethod);
        Console.WriteLine("  |-Username     : {0}", vdir.UserName);
        Console.WriteLine("  +-Password     : {0}", vdir.Password);
    }
}
    }
}

Applies to