473,748 Members | 3,585 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web page to enumerate groups in active directory

9 New Member
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is created they can tell me who they want their account to be modeled after. The html app works great as a .hta file but when it is saved as a web page it won't list the members of any groups. I get an error on line 182: "ActiveX component can't create object: 'GetObject'" Here is the line that throws the error: "Set objRootDSE = GetObject("LDAP ://RootDSE")" Here is the code:
[html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Group Enumerator</title>
<style type="text/css">
/* Default CSS Stylesheet for a new Web Application project */
body{background-color:#cdd4e6; margin:20 20 20 0; color:#444444;}
td{font-family:Arial, Helvetica, sans-serif; font-size:11px;}
select{font-family:Arial, Helvetica, sans-serif; font-size:11px;}
input{font-family:Arial, Helvetica, sans-serif; font-size:11px;}
a{font-family:Arial, Helvetica, sans-serif; font-size:11px;color :#444444;}
/* Custom */
td.header{backg round-color:#7f92bf; color:#ffffff; font-size: 20px; padding-left:15px;}
td.content{padd ing:15 15 15 15; background-color:#ffffff;}
td.title{color: #7f92bf; font-size:10px;}
td.error{color: #ff0000}
/* Tabs */
a.tablink{font-weight:bold;tex t-decoration:none ;}
.tabline{border-bottom:1px solid #CCCCCC}
.tab{border-top:1px solid #CCCCCC;border-right:1px solid #CCCCCC;border-bottom:1px solid #CCCCCC;padding :3 5 3 5;border-left:1px solid #CCCCCC;backgro und-color:#eeeeee}
.tabactive{bord er-top:1px solid #CCCCCC;border-right:1px solid #CCCCCC; border-left:1px solid #CCCCCC;padding :3 5 3 5;}
/* Grid */
td.gridheader{p adding:3 3 3 3; font-weight:bold; background-color:#eeeeee;}
td.gridcell{pad ding:3 3 3 3;border-bottom:1px solid #eeeeee}
</style>
[/html]

Expand|Select|Wrap|Line Numbers
  1. <script language="VBScript">
  2.     Const DOMAIN                 = "luiginos.com" 
  3.     'ou's to ignore when making groups available security related or obsolete
  4. '    Const OUS_TO_IGNORE            = "OU=this,OU=that,OU=theother,DC=WINDOWSITPRO,DC=tld OU=obsolete,DC=WINDOWSITPRO,DC=tld"
  5.     Const OUS_TO_IGNORE            = ""
  6.     Dim Searchtype
  7.     Dim strUserName
  8.     Dim objUser
  9.     Dim bUserLoaded
  10.     Dim arrUserGroups
  11.     Dim    intSecCount 
  12.     Dim intDistCount    
  13.     Dim strGroupChosen
  14.     bUserLoaded = False
  15. ' ======= Standardized Arrays 
  16.     Dim arrSecGroup(500)
  17.     Dim arrDistGroup(500)
  18.  
  19. Sub window_Onload
  20.     Const ADS_SCOPE_SUBTREE = 2
  21.     Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000
  22.     Set objConnection = CreateObject("ADODB.Connection")
  23.     Set objCommand =   CreateObject("ADODB.Command")
  24.     objConnection.Provider = "ADsDSOObject"
  25.     objConnection.Open "Active Directory Provider"
  26.     Set objCommand.ActiveConnection = objConnection
  27.     objCommand.Properties("Page Size") = 1000
  28.     objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
  29.     objCommand.Properties("Sort On") = "name"
  30.     objCommand.CommandText = _
  31.         "<LDAP://" & DOMAIN & ">;(&(objectCategory=GROUP));Name,grouptype,distinguishedName;Subtree"  
  32.     Set objRecordSet = objCommand.Execute
  33.     objRecordSet.MoveFirst
  34.     intSecCount = 1
  35.     intDistCount = 1
  36.     Do Until objRecordSet.EOF
  37.         tmpDGN = objRecordSet.Fields("distinguishedName").Value
  38.         If      InStr(1,OUS_TO_IGNORE,Right(tmpDGN, Len(tmpDGN) - InStr(1,tmpDGN,",",1)),1) = 0  Then
  39.             If  objRecordSet.Fields("Grouptype").Value And ADS_GROUP_TYPE_SECURITY_ENABLED  Then    
  40.                 arrSecGroup(intSecCount) = objRecordSet.Fields("Name").Value
  41.                 intSecCount = intSecCount + 1
  42.             Else
  43.                 arrDistGroup(intDistCount) = objRecordSet.Fields("Name").Value
  44.                 intDistCount = intDistCount + 1
  45.             End If
  46.         End If 
  47.         objRecordSet.MoveNext
  48.     Loop
  49.     'fill up group boxes
  50.      FillGroups arrSecGroup,     intSecCount,  document.all.boxSecurity
  51.      FillGroups arrDistGroup, intdistCount, document.all.boxDistribution
  52.     Set objConnection = Nothing
  53.     Set objCommand = Nothing
  54.     Set objRecordSet = Nothing
  55. End Sub
  56.  
  57.     Sub StartUserHTA
  58.         Set WshShell = CreateObject("WScript.Shell")
  59.         strCmdLine = ".\HD-Dash-USER.hta"
  60.         WSHShell.Run strCmdLine,8    
  61.     End Sub
  62.  
  63. Sub Get_Distribution
  64.     document.all.boxSecurity.SelectedIndex = Null
  65.     For Each objOption In document.all.objMembership.Options
  66.         objOption.RemoveNode
  67.     Next 
  68.     strGroupChosen = "Distribution group - " & arrDistGroup(document.all.boxdistribution.selectedIndex)
  69.     EnumMembers arrDistGroup(document.all.boxdistribution.selectedIndex), "", ""
  70. End Sub
  71.  
  72. Sub Get_Security
  73.     document.all.boxdistribution.SelectedIndex = Null
  74.     For Each objOption In document.all.objMembership.Options
  75.         objOption.RemoveNode
  76.     Next 
  77.     strGroupChosen = "Security group - " & arrSecGroup(document.all.boxSecurity.selectedIndex)
  78.     EnumMembers arrSecGroup(document.all.boxSecurity.selectedIndex), "", ""
  79. End Sub
  80.  
  81. ' What: Fills in Group boxes both Security and ditribution
  82. ' Input: arrGroup is the array to fill with, intGroupCount is how many itmes in the array and PaneName
  83. '            is where the information should be place
  84. ' output:     Security and distrubution panes are filled.
  85.  
  86.     Sub FillGroups (arrGroup, intGroupCount, PaneName)
  87.         For Each objOption In PaneName.Options
  88.             objOption.RemoveNode
  89.         Next 
  90.         Set objOption = document.createElement("OPTION")
  91.         objOption.Text = "<CHOOSE A GROUP>"
  92.         objOption.Value = 0 
  93.         PaneName.Add(objOption)
  94.         For intIncrement = 1 To intGroupCount
  95.             If arrGroup(intIncrement) <> "" Then 
  96.                         Set objOption = document.createElement("OPTION")
  97.                         objOption.Text = arrGroup(intIncrement)
  98.                         objOption.Value = i 
  99.                         PaneName.Add(objOption)
  100.             End If
  101.         Next 
  102.         Set objOption = Nothing 
  103.     end Sub
  104.  
  105. Sub EnumMembers(strName, strOffset, strGOffset)
  106. ' Recursive subroutine to enumerate members of a group,
  107. ' including nested group memberships.
  108.     Dim strFilter, strQuery, objRecordSet, k, objMember, objCommand
  109.     Dim strDN, intCount, blnLast, intLowRange, objConnection
  110.     Dim intHighRange, intRangeStep, objField
  111.     Dim iCount, objGroup, strAttributes
  112.     Dim  strNTName, objRootDSE, strDNSDomain 
  113.     Dim  strBase, objGroupList
  114.     Dim objMemList
  115.      strAttributes = "member, sn"
  116.     If strGOffset = "" Then
  117.         strGOffset = "+"
  118.     End If 
  119.      Set objRootDSE = GetObject("LDAP://RootDSE")
  120.     strBase = "<LDAP://" & objRootDSE.Get("DefaultNamingContext") & ">"
  121.   ' Filter on objects of class "group" and specified name.
  122.       strFilter = "(&(ObjectCategory=group)" & "(ObjectClass=group)" & "(Name=" & strName & "))"
  123.     strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
  124. ' Use ADO to search Active Directory.
  125.     Set objCommand = CreateObject("ADODB.Command")
  126.     Set objConnection = CreateObject("ADODB.Connection")
  127.     objConnection.Provider = "ADsDSOObject"
  128.     objConnection.Open = "Active Directory Provider"
  129.     objCommand.ActiveConnection = objConnection
  130.     objCommand.Properties("Page Size") = 100
  131.     objCommand.Properties("Sort On") = "sn"
  132.     objCommand.Properties("Timeout") = 30
  133.     objCommand.Properties("Cache Results") = False
  134.     objCommand.CommandText = strQuery
  135.     Set objRecordSet = objCommand.Execute
  136.     Do Until objRecordSet.EOF
  137.         For Each objField In objRecordSet.Fields
  138.             If IsArray(objField.Value) Then
  139.                 objMemList = SingleSorter(objField.Value)
  140.                 i = 1
  141.                   For Each strDN In objMemList
  142.                     Set objGroup = GetObject("LDAP://" & strDN & "")
  143.                     IF LCase(objGroup.Class) = "group" Then
  144.                          Set objOption = document.createElement("OPTION")
  145.                          objOption.Text = strGOffset & objGroup.cn
  146.                          objOption.Value = objGroup.cn 
  147.                          document.all.objMembership.Add(objOption)
  148.                          strOffset = strOffset + "-"
  149.                          strGOffset = strGOffset + "+"
  150.                         Call EnumMembers(objGroup.cn, strOffset, strGOffset)
  151.                     Else
  152.                          Set objOption = document.createElement("OPTION")
  153.                          objOption.Text = strOffset & objGroup.cn
  154.                          objOption.Value = objGroup.cn 
  155.                          document.all.objMembership.Add(objOption)
  156.                     END If
  157.                     intCount = intCount+1
  158.                        iCount=iCount+1
  159.                   Next
  160.               End If
  161.         Next
  162.       objRecordSet.MoveNext
  163.     Loop
  164.     If strOffset  <> "" Then
  165.         strOffset = Right(strOffset, Len(strOffset) - 1)
  166.     End If
  167.     If strGOffset  <> "" Then
  168.         strGOffset = Right(strGOffset, Len(strGOffset) - 1)
  169.     End If
  170. End Sub
  171.  
  172. </script>
  173.  
[html]
<form id="frmPage" action="">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td height="50" class="header"> Group Enumerator</td>
</tr>
<tr>
<td class="content" height="100%" valign="top">
<table cellSpacing="0" cellPadding="0" border="1">
<tr>
<td class="title">D istribution Groups</td>
<td class="title">S ecurity Groups</td>
<td class="title">G roup Membership</td>
</tr>
<tr>
<td class="title"> <select size="20" name="boxDistri bution" onChange="vbscr ipt:Get_Distrib ution"></select></td>
<td class="title"> <select size="20" name="boxSecuri ty" onChange="vbscr ipt:Get_Securit y"></select></td>
<td class="title"> <select size="20" name="objMember ship" ></select></td>
</tr>
</td>
</table>
<table cellSpacing="0" cellPadding="0" border="0">
<tr>
<td>
<input id=QuitButton class="button" type="button" value="Quit" name="Quit_butt on" onClick="Quit_H TA">
</td>
<td>
<!--
<input id=DistButton class="button" type="button" value="Export Distrbution groups to Excel" name="Dist_butt on" onClick="Export _dist">
-->
</td>
<td>
<!--
<input id=SecButton class="button" type="button" value="Export Security groups to Excel" name="Sec_butto n" onClick="">
-->
</td>
<td>
<input id=MemButton class="button" type="button" value="Export Results" name="Mem_butto n" onClick="PopExc elGroups">
</td>
</tr>
</table>
</form>
</body>
</html>
[/html]
Mar 27 '07 #1
0 2505

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6626
by: Marko Faldix | last post by:
Hello, I am looking for a language to achieve lists of all NT users and groups of a given NT domain on a Windows 2000 Server. It has to run within a webscript, so vbscript with windows scripting host is considered first. But before I dive into this, isn't it possible to do it with win32all? An ideal result would be something like the listings one get while changing file permissions on a file on a NT machine. I think, this extends too...
5
5893
by: Aaron_TekRecycle.com | last post by:
Someone must have done this before?!? I have VBS code that will Enumerate all the Printers in the AD and Add the Printer Connection to the client... I'm just not a web developer so I need some example code or hand-holding on the web integration portion. Anyone? "Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
5
2048
by: Jeff Grundy | last post by:
How do I enumerate the machines domain, then enumerate the shares of a machine?
0
1316
by: news | last post by:
I have one Active Directory Group that contains users and groups objects. I need recursively call my function to get all users that are in the group and subgroups. All is working fine, when i select as first group an Domain Local Group. In case I select Domain Global Group, something is wrong. I get only one user, or any user.... What to do?
2
2910
by: Daniel G | last post by:
Hello, I am working at a ASP.NET project that uses authenticate/authorize via Active Directory. There are many groups with different roles. I am unable to 'see' a solution for this kind of error : - for a specific user X ( that belongs to group G1 and G2) this call : DirectoryEntry.Invoke("Groups")
1
1234
by: RTT | last post by:
i can search the active directory to find the groups and i can search users and find out of what groups he's a member. But now i have to find a group, and find out what groups he's a member of, but i don't know where to start.... anybody who has an idea? thxs in advance
0
1717
by: damiensawyer | last post by:
Hello all, I'm very new to all of this. I have a theme and a skin (the standard ones). I have a standard master page which is holding a custom ascx which has a treeview in it. Can someone please point me in the right direction to bind a theme to the treeview? The 'theme' tag is on the <%@ page %> directive... however neither my master page or ASCX files use this. They use <%Master%> and
3
4816
by: interuser | last post by:
Hi I want to enumerate all groups of an active directory. How do I do that? Thanks
2
2761
by: rote | last post by:
My sceanrio is this on an asp.net 2.0 freamework. I want to use any of the data controls e.g Gridview,DetailView etc.. But i want some buttons e.g update,edit save etc to be enable or disabled based on if they belong to some security groups in active directory. I'm looking for the best options for this because i want to store those security groups somewhere and then check for the user against those security groups for their authorisation...
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.