Does anyone know how to programmatically determine
if a membership server instance is mapped to an IIS site or virtual directory? I
can use the following vbscript code below to get the authentication type out of
the IIS Metabase, but there is no way to tell if the site or directory is mapped
to an instance of membership server or not, and also what type of authentication
site server is using (i.e. HTML Forms Authentication, Cookie Authentication,
etc).
Here is the code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This
script will query the IIS Metabase to see what type of
'authentication
method(s) are being used.
'
'Author: Tim McCarthy
'Date:
4/6/2000
'Inputs:
' Site Number
' Virtual Directory
Name
'Output:
' Authentication
method(s)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Call GetAuthentication()
Private Sub GetAuthentication()
On Error Resume Next
'Anonymous authentication
Const
MD_AUTH_ANONYMOUS = 1
'Basic authentication
Const
MD_AUTH_BASIC = 2
'Disgest authentication
Const
MD_AUTH_DIGEST = 16
'Integrated Windows
authentication
Const MD_AUTH_NT = 4
Dim ComputerObj
Dim
MaxBW
Dim AuthFlags
Dim strAuthType
Dim
intSiteNumber
Dim strVirtualName
Dim strIISProgID
Dim
strAppName
'Set the name of the app for message
boxes
strAppName = "IIS Authentication Settings"
'Get the site number
intSiteNumber =
InputBox("Please enter 1 for the main site, 2 for the next, etc.")
If
IsNumeric(intSiteNumber) = False
Then
intSiteNumber =
1
Else
If intSiteNumber < 1
Then
intSiteNumber =
1
End If
End If
'Get the virtual directory
name
strVirtualName = InputBox("Please enter a virtual directory name,
if any.")
'Build the ProgID
strIISProgID =
"IIS://LocalHost/W3SVC/" & intSiteNumber & "/ROOT"
'Test if a virtual directory was
entered
If Len(Trim(strVirtualName)) > 0 Then
'Append the virtual
directory to the ProgID
strIISProgID =
strIISProgID & "/" & strVirtualName
End If
'Create instance of IIS Metabase
Set
ComputerObj = GetObject(strIISProgID)
'Test for errors
If Err.Number
<> 0 Then
strErrorMessage = "You have
entered in an invalid site number or virtual directory
name."
MsgBox strErrorMessage, vbCritical,
strAppName
Exit Sub
End
If
'Get the AuthFlags
property
AuthFlags = ComputerObj.AuthFlags
Set ComputerObj =
Nothing
strAuthType = "You are using the "
Select Case AuthFlags
'The 4 main
authentication types
Case
MD_AUTH_ANONYMOUS
strAuthType = strAuthType & "Anonymous
access"
Case
MD_AUTH_BASIC
strAuthType = strAuthType & "Basic"
Case
MD_AUTH_DIGEST
strAuthType = strAuthType & "Digest"
Case
MD_AUTH_NT
strAuthType = strAuthType & "Integrated
Windows"
'Combinations of the
4 main authentication types
Case
MD_AUTH_ANONYMOUS + MD_AUTH_BASIC
strAuthType = strAuthType & "Anonymous access and
Basic"
Case MD_AUTH_ANONYMOUS + MD_AUTH_BASIC
+ MD_AUTH_DIGEST
strAuthType = strAuthType & "Anonymous access, Basic and
Digest"
Case MD_AUTH_ANONYMOUS + MD_AUTH_BASIC
+ MD_AUTH_NT
strAuthType = strAuthType & "Anonymous access, Basic and Integrated
Windows"
Case MD_AUTH_ANONYMOUS +
MD_AUTH_BASIC + MD_AUTH_DIGEST +
MD_AUTH_NT
strAuthType = strAuthType & "Anonymous access, Basic, Digest, and Integrated
Windows"
Case MD_AUTH_ANONYMOUS +
MD_AUTH_DIGEST
strAuthType = strAuthType & "Anonymous access and
Digest"
Case MD_AUTH_ANONYMOUS +
MD_AUTH_DIGEST + MD_AUTH_NT
strAuthType = strAuthType & "Anonymous access, Digest and
Integrated Windows"
Case MD_AUTH_ANONYMOUS +
MD_AUTH_NT
strAuthType = strAuthType & "Anonymous access and Integrated
Windows"
Case MD_AUTH_BASIC +
MD_AUTH_DIGEST
strAuthType = strAuthType & "Basic and
Digest"
Case MD_AUTH_BASIC + MD_AUTH_DIGEST +
MD_AUTH_NT
strAuthType = strAuthType & "Basic, Digest, and Integrated
Windows"
Case MD_AUTH_BASIC +
MD_AUTH_NT
strAuthType = strAuthType & "Basic and Integrated
Windows"
Case MD_AUTH_DIGEST +
MD_AUTH_NT
strAuthType = strAuthType & "Digest and Integrated
Windows"
'Any unknown authentication
type or combination
Case
Else
strAuthType =
"Unknown (AuthFlags = " & AuthFlags & ")"
End
Select
strAuthType = strAuthType & " Authentication
Method(s)."
MsgBox strAuthType, , strAppName
End
Sub