<%
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
%>
error '80005004'
/uid.asp, line 9
Originally posted by Carefree
First thing that pops into my head is to verify that your Win 2003 server is using "WinNT" as the windows directory. The default is "Windows".
Originally posted by AnonJr
Its been a while since I last looked, so details are a little fuzzy, but GetObject("WinNT://<ServerName>/" & sGroupName) is the older API and will work for basic information in later versions of sever. If I remember right, you will need to use a different API to get the detailed group information you want.
<%
Dim sCurrentGroup
Dim sDomainName
sCurrentGroup = "Group1"
sDomainName = "MYSERVER"
'Change the following line so that sDomainName is your machine name or domain name
If sDomainName = "" Then sDomainName = "MYSERVER"
%>
<html>
<head>
</head>
<body>
<%
If sCurrentGroup <> "" Then
Response.Write ListUsers(sDomainName, sCurrentGroup)
End if
%>
</body>
</html>
<%
' Function to list the users and groups within a specific user group.
' Function must be supplied with two arguments:
' sDomainName: The domain name or computer name
' sGroupName: The name of the user group
Function ListUsers(sDomainName, sGroupName)
Dim sUserList
Dim sMyParent
Set Group = GetObject("WinNT://" & sDomainName & "/" & 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
sUserList = sUserList & Member.Name & "<br>"
End If
Next
ListUsers = sUserList
End Function
%>