VirtualDirectory.UserName 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 user name that the virtual directory uses to access its configured physical location.
public:
property System::String ^ UserName { System::String ^ get(); void set(System::String ^ value); };
public string UserName { get; set; }
member this.UserName : string with get, set
Public Property UserName As String
Property Value
The user name that the virtual directory uses to access its physical location.
Examples
The following example demonstrates how to set the UserName property of a virtual directory.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;
namespace AdministrationSnippets
{
public class AdministrationAuthenticationLogonMethod
{
// Creates a new virtual directory and sets the logon method.
public void SetLogonMethod()
{
ServerManager manager = new ServerManager();
Site defaultSite = manager.Sites["Default Web Site"];
Application reports = defaultSite.Applications.Add(
"/reports", @"\\FileServer\Reports");
// Configure the default virtual directory for the application.
VirtualDirectory reportDir = reports.VirtualDirectories[0];
reportDir.LogonMethod = AuthenticationLogonMethod.Batch;
reportDir.UserName = @"HumanResources\Jane";
reportDir.Password = @"iL@1Fnw!";
manager.CommitChanges();
}
}
}
Remarks
You should use this property when the virtual directory requires alternative credentials to access secured content, such as a UNC path.