The following function works on Windows 2000 and not Windows 2003. Do I have to install a driver or enable something on Windows 2003 to make it work. I should say that I created two user groups (Local Users and Groups) on the server and called them 'Group1' and 'Group2'.
<%
Group1=isValidGroup("Group1")
Group2=isValidGroup("Group2")
Function isValidGroup(sGroupName)
isValidGroup=0
UID = ucase(request.servervariables("LOGON_USER"))
UName = mid(UID,instr(UID,"\") +1)
Set Group = GetObject("WinNT://<ServerName>/" & sGroupName)
For Each Member in Group.Members
On Error Resume Next
sMyParent = Member.Parent
sMyParent = Right(sMyParent, Len(sMyParent) - InStrRev(sMyParent, "/"))
If Member.Class = "User" Then
If ucase(UName)=ucase(Member.Name) Then
isValidGroup=1
Exit For
End If
End If
Next
End Function
%>
<%
If Group1=1 or Group2=1 Then
Response.Write "Access Granted"
Else
Response.Write "Access Denied"
End If
%>
..and here is the error message. Line 9 is in red above.
error '80005004'
/uid.asp, line 9
I got the idea from Snitz forum file 'inc_common_function.asp' lines 812 and 822.