VirtualDirectoryDefaults.Password Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the password that is used by default for all virtual directories under the current context.
public:
property System::String ^ Password { System::String ^ get(); void set(System::String ^ value); };
public string Password { get; set; }
member this.Password : string with get, set
Public Property Password As String
Property Value
The default clear-text password for all virtual directories under the current context.
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);
}
}
}
}
Remarks
You should use this property when the virtual directory requires alternative credentials to access secured content, such as a UNC path. When you set the password for a virtual directory, the value stored in the configuration system is encrypted. The value set on this property is used by default for all virtual directories in the current context when a password is not explicitly set.
Caution
The value returned from the get
accessor of this property is clear text. Use care when you display this value in an unsecured environment.