Tag Archives: directory

Apache: Protect a folder by a password, but one file is for public access

Hi,

let us assume you want to protect a whole directory by password and but one file must be readable for public access. This can easily be done by a .htaccess file.

For example: Who want to trotect the folder /var/www/html and only the file public.html should be readable without a password.
Continue reading Apache: Protect a folder by a password, but one file is for public access

Windows: Script to get the NetBIOS Name of an Active Directory Domain

Hi,

just a short post :-). A powershell script to get the NetBIOS Name of an Active Directory Domain


###############################################################################
# Gets the NetBIOS Domain
# Author Michael Albert michlstechblog.info
# License: GPL v2
###############################################################################
[reflection.assembly]::LoadWithPartialName("System.DirectoryServices.Protocols")|Out-Null

if($args.count -ne 1){
    Write-Warning " Start script with fqdn as parameter"
    Write-Warning (" for example: "+$myInvocation.myCommand.name+" yourdomain.com")
    exit 1
}
$sDomainName=$args[0]
# Get AD Root
$oRootDSE = [ADSI]"LDAP://RootDSE"
$sConfig = $oRootDSE.Get("configurationNamingContext")
# AD Object AD Root
$oADSearchRoot=New-object System.DirectoryServices.DirectoryEntry("LDAP://CN=Partitions," + $sConfig)
# Search for Netbiosname of the specified domain
$sSearchString="(&(objectclass=Crossref)(dnsRoot="+$sDomainName+")(netBIOSName=*))"
$oSearch=New-Object directoryservices.DirectorySearcher($oADSearchRoot,$sSearchString)
$sNetBIOSName=($oSearch.FindOne()).Properties["netbiosname"]
# Print out
Write-Host "Domain NetBIOS Name:" $sNetBIOSName

Have fun :-)!

Michael

Apache: Alias directive for virtual directory returns HTTP Error 403

Hi,

I have added a virtual directory to an apache web server and the virtual directory is located outside the document root. I configured the httpd.conf how it is decripted in the apache doc

When I access the virtual directory an error “Access forbidden! Error 403” occured. The config seems to ok:

Alias /virtualdirectory/ "D:/user/www/virtual/"
<Directory "D:/user/www/virtual/">
   Options Indexes FollowSymLinks MultiViews ExecCGI
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

Solution:

The default apache configration is very restrictive. It do not allow to access directories without authentication. This is defined in the Directory section of httpd.conf:


<Directory>
   AllowOverride none
   Require all denied
</Directory>

Add a “require all granted” directive to your virtual directory section will grant the access.

Alias /virtualdirectory/ "D:/user/www/virtual/"
<Directory "D:/user/www/virtual/">
   Options Indexes FollowSymLinks MultiViews ExecCGI
   AllowOverride All
   Order allow,deny
   Allow from all
   Require all granted
</Directory>