Windows Groups - Postet den (1323 Views)
Junior Member
mafifi
Innlegg: 308
308
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'.
Code:

<%
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.
Code:

error '80005004' 
/uid.asp, line 9

I got the idea from Snitz forum file 'inc_common_function.asp' lines 812 and 822.
Regards,

Mo
   
 Sidestørrelse 
Postet den
Advanced Member
Carefree
Innlegg: 4224
4224
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".
Postet den
Forum Moderator
AnonJr
Innlegg: 5768
5768
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.
Postet den
Forum Moderator
AnonJr
Innlegg: 5768
5768
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".

The WinNT in this case is not the directory, its a reference to an older Active Directory API. wink
Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
it could be a permission issue, 2003 is locked down a lot tighter than 2000
Postet den
Junior Member
mafifi
Innlegg: 308
308
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.

This is driving me nuts. The following function worked on the same server where the other function did not work:
Code:
<%
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
%>

The result of the function is to list all the users in 'Group1'.
Regards,

Mo
Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
your problem is probably here then and not the getobject at all

UID = ucase(request.servervariables("LOGON_USER"))
UName = mid(UID,instr(UID,"\") +1)

might be worth checking what UID and Uname equal using some response.writes
 
Du må legge inn en melding