Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Windows Groups
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mafifi
Junior Member

USA
308 Posts

Posted - 21 April 2010 :  20:49:15  Show Profile  Reply with Quote
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.

Regards,

Mo

Carefree
Advanced Member

Philippines
4224 Posts

Posted - 22 April 2010 :  05:08:05  Show Profile  Reply with Quote
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".
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 22 April 2010 :  07:01:19  Show Profile  Visit AnonJr's Homepage  Reply with Quote
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.
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 22 April 2010 :  07:02:47  Show Profile  Visit AnonJr's Homepage  Reply with Quote
quote:
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.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20611 Posts

Posted - 22 April 2010 :  09:59:56  Show Profile  Visit HuwR's Homepage  Reply with Quote
it could be a permission issue, 2003 is locked down a lot tighter than 2000

MVC .net dev/test site | Snitz .NET Core running on Raspberry Pi

Go to Top of Page

mafifi
Junior Member

USA
308 Posts

Posted - 22 April 2010 :  14:36:35  Show Profile  Reply with Quote
quote:
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:
<%
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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20611 Posts

Posted - 22 April 2010 :  14:46:28  Show Profile  Visit HuwR's Homepage  Reply with Quote
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

MVC .net dev/test site | Snitz .NET Core running on Raspberry Pi

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000 Version 3.4.07