Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Windows Login Page Restriction

Posted on August 19, 2013October 26, 2015 By David Kittell

Sometimes you have to restrict the visitor of a page to a username, if you don’t want to take the time to build a database you can simply use the username on the domain.

In the code below make sure you replace “<DOMAIN>” with your companies domain

protected void Page_Load(object sender, EventArgs e)
	{
		System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;

		string sEmployee = p.Identity.Name.Replace("<DOMAIN>", "").ToLower();

		//Response.Write(sEmployee);

		switch (sEmployee)
		{
			default:
				Response.Redirect("http://www.kittell.net");
				break;
			case "dkittell":
			case "testuser1":
			case "testuser2":
				break;
		}

	}
Originally Posted on August 19, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

C# ASPX Code CSharp

Post navigation

Previous post
Next post

Related Posts

Age Verification

Posted on December 16, 2013October 26, 2015

private bool ValidateMemberUnderage(DateTime dtBirthday, int nYears) { if (DateTime.Today.Year – dtBirthday.Year > nYears) return true; else if (DateTime.Today.Year – dtBirthday.Year == nYears) { DateTime dtBirthdayThisYear = dtBirthday.AddYears(nYears); if (DateTime.Today >= dtBirthdayThisYear) return true; else return false; } else return false; } if (ValidateMemberUnderage(DateTime.Parse("1981-04-04"), 12) == false) { MessageBox.Show("Too Young"); }…

Read More

PowerShell Get All Environment Variables

Posted on November 6, 2015

If you need to know some of the system variables that are already set you can run this script to get the values Get-Childitem env: gci env: | sort name Once you know what variable you want you can do something like this Write-Host "Computer:`t" $env:COMPUTERNAME Write-Host "Domain:`t" $env:USERDOMAIN All…

Read More

Oracle Clean Date Format

Posted on September 18, 2013October 26, 2015

Sometimes you have to pull a date from Oracle in a cleaner format, this is one way to achieve the format you want. // Convert the Oracle date 19000101 to 01-01-1900 public string OracleCleanDate(string strDate) { if (strDate.Length == 8) { string strYear, strMonth, strDay; strYear = strDate.Substring(0, 4); strMonth…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes