非常感谢.原来需要检查member的adspath属性值.我对CK_MemberInGroup函数稍作了一点修改.如下:
Function CK_MemberInGroup(S_Member,S_Group)
CK_MemberInGroup="F"
sDomainName = "127.0.0.1"
On Error Resume Next
Set Group = GetObject("WinNT://" & sDomainName & "/" & S_Group & ",Group" )
if Err.number<>0 then
exit function
end if
For Each Member in Group.members
If Member.Class <> "Group" Then
if Member.adspath=S_Member then
CK_MemberInGroup="T"
exit function
end if
end if
Next
End Function
MsgBox(ck_memberingroup("WinNT://domain/user","administrators"))
下面的代码就是检查用户是否被包含在指定的组中
<%
sGroupName = "PkGroup"
sDomainName = "Kenfilszwin2k"
Function CK_MemberInGroup(S_Member,S_Group)
CK_MemberInGroup="F"
On Error Resume Next
Set Group = GetObject("WinNT://" & sDomainName & "/" & sGroupName & ",Group" )
if Err.number<>0 then
exit function
end if
For Each Member in Group.members
If Member.Class <> "Group" Then
if member.name=S_Member then
CK_MemberInGroup="T"
exit function
end if
end if
Next
End Function
response.write ck_memberingroup("benny","pkgroup")
%>
下面这段代码把sDomainName 定义为你的机名获得的就是本地组用户
<%
Dim sCurrentGroup
Dim sDomainName
sCurrentGroup = Request.QueryString("Group")
sDomainName = Request.QueryString("Domain")
'Change the following line so that sDomainName is
'your machine name or domain name
If sDomainName = "" Then
'sDomainName = "Kenfilszwin2k"
sDomainName = "Kenfilce_server"
end if
%>
<P>Exploring the Domain <%=sDomainName%></P>
<form name="frmGroupSelector" action="UserGroupBrowser.asp" method="GET">
<input type="hidden" name="Domain" value="<%=sDomainName%>">
<%=ListGroups(sDomainName, sCurrentGroup, "submitFrm()")%>
</form>
<%
If sCurrentGroup <> "" Then
Response.Write ListUsers(sDomainName, sCurrentGroup)
End if
%>
<script language="JavaScript"><!--
function submitFrm() {
if (document.frmGroupSelector.Group.options[document.frmGroupSelector.Group.selectedIndex].value != '')
{
document.frmGroupSelector.submit();
}
}
//--></script>
<%
'function to create a select list containing a list of groups within a computer
'or domain. Function must be supplied with three arguments:
'sDomainName: The domain name or computer name
'sSelectedGroup: The name of the group that should have the selected attribute
'sOnChangeScript: The name of the JavaScript function that should be executed
' when the onChange event is triggered for this select list
Function ListGroups(sDomainName, sSelectedGroup, sOnChangeScript)
End Function
%>
<%
'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)