home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / ASP / WAB / group.asp < prev    next >
Encoding:
Text File  |  1999-03-11  |  5.0 KB  |  180 lines

  1. <%
  2.  Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2
  3.  Const ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = &H4
  4.  Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &H8
  5.  Const ADS_GROUP_TYPE_SECURITY_ENABLED = &H80000000
  6.  
  7.   ADsDomain = Session("ADsDomain")
  8.   'Session may time out
  9.   If ADsDomain = "" then
  10.     ADsDomain = Application("ADsDomain")
  11.   End if
  12.  
  13.  
  14.   'Parse the URL path into adsPath
  15.   urlPath = Request.QueryString("anr")
  16.   userID = Application("UserID")
  17.   password = Application("Password")
  18.   domainPath = "LDAP://" & ADsDomain
  19.  
  20.   counter = 0
  21.   idx = 1
  22.   adsPath = ""
  23.   While idx <> 0
  24.       idx = InStr(1, urlPath, "%20")
  25.       If (idx = 0) Then
  26.          adsPath = adsPath & Mid(urlPath, 1)
  27.       Else
  28.          adsPath = adsPath & Mid(urlPath, 1, idx - 1)
  29.         adsPath = adsPath & " "
  30.       End If
  31.       urlPath = Mid(urlPath, idx + 3)
  32.    Wend
  33.    Set dso = GetObject("LDAP:")
  34.    '--- TIME BEGIN ----
  35.    t = Timer 
  36.    Set o = dso.OpenDSObject( adsPath, userID, password, 1 )
  37.    elapse = Mid(CStr(Timer - t),1,5)
  38.    '---TIME END ---------
  39.  
  40.    if ( o.Class <> "group" ) then
  41.         Set o = Nothing
  42.         Set dso = Nothing
  43.         Response.Redirect "person.asp?anr=" & Request.QueryString("anr")
  44.    end if 
  45.  
  46.       
  47. %>
  48. <html>
  49.  
  50. <head>
  51. <meta name="GENERATOR" content="Microsoft FrontPage 3.0">
  52. <title>Group Information</title>
  53. </head>
  54.  
  55. <body>
  56.  
  57. <p><img src="banner.gif" width="232" height="52" alt="banner.gif (3494 bytes)">
  58.         <a href="default.asp"><img src="search.gif"
  59. width="39" height="39" alt="search.gif (1222 bytes)" border="0"></a></p>
  60.  
  61.  
  62. <%
  63.  
  64.   On Error Resume Next
  65.    members = o.Get("member")
  66.    groupType = o.Get("groupType")
  67.  
  68.  
  69.  
  70.    if ( groupType And  ADS_GROUP_TYPE_SECURITY_ENABLED ) then
  71.      groupDesc = "Security Group "
  72.   else
  73.      groupDesc = "Distribution List "
  74.   end if   
  75.  
  76.    if ( groupType And ADS_GROUP_TYPE_GLOBAL_GROUP ) Then
  77.          groupDesc = groupDesc & "(Global)"
  78.    ElseIf ( groupType And ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP ) Then
  79.           groupDesc = groupDesc & "(Domain Local)"
  80.    ElseIf ( groupType And ADS_GROUP_TYPE_UNIVERSAL_GROUP ) Then
  81.           groupDesc = groupDesc & "(Universal)"
  82.    end if 
  83.  
  84.     'Get the owner
  85.     ownerPath = domainPath & "/" &o.Get("managedBy")
  86.     if ( Err.Number = 0 ) then
  87.       idxStart = InStr(1, ownerPath, "=")
  88.       idxEnd   = InStr(idxStart, ownerPath, ",")
  89.       owner = Mid(ownerPath, idxStart+1, idxEnd - idxStart -1 ) 
  90.     end if 
  91.  
  92.  
  93. %>
  94.  
  95.  
  96. <table border="0" cellpadding="2" width="100%">
  97.   <tr>
  98.     <td width="17%" align="right" bgcolor="#0080C0"><font face="Verdana" color="#FFFFFF"><strong><small>Group</small></strong></font></td>
  99.     <td width="83%"><font face="Verdana" color="#0080C0"><small><%Response.Write o.Get("cn")%></small></font></td>
  100.   </tr>
  101.   <tr>
  102.     <td width="17%" align="right" bgcolor="#0080C0"><font face="Verdana" color="#FFFFFF"><strong><small>Group
  103.     Type:</small></strong></font></td>
  104.     <td width="83%"><font face="Verdana" color="#0080C0"><small><%Response.Write groupDesc%></small></font></td>
  105.   </tr>
  106.   <tr>
  107.     <td width="17%" align="right" bgcolor="#0080C0"><font face="Verdana" color="#FFFFFF"><strong><small>Owner:</small></strong></font></td>
  108.     <td width="83%"><font face="Verdana" color="#0080C0"><small>
  109.     <a href="person.asp?anr=<%Response.Write ownerPath%>" ><%Response.Write owner%></a></small></font></td>
  110.   </tr>
  111.  
  112. </table>
  113.  
  114. <p> </p>
  115.  
  116. <table border="0" cellpadding="1" cellspacing="2" width="100%">
  117.   <tr>
  118.     <td width="100%" bgcolor="#0080C0"><font face="Verdana" color="#FFFFFF"><strong><small>  
  119.     Group Members</small></strong></font></td>
  120.   </tr>
  121. <% for each member in members 
  122.      
  123.      'Alternate background color for enhancing the appearance 
  124.      counter = counter + 1 
  125.       md = counter mod 2 
  126.       if ( md = 0 ) then 
  127.          bkColor = "#C9C9C9"
  128.       else
  129.          bkColor = "#E8E8E8"
  130.       end if 
  131.   %>
  132.   <tr>
  133. <%  
  134.     idxStart = InStr(1, member, "=") + 1
  135.     idxEnd = InStr(1, member, ",")
  136.     rdnMember = Mid(member, idxStart, idxEnd - idxStart)
  137.     refMember = domainPath & "/" & member 
  138.  
  139. %>
  140.     <td width="100%" bgcolor="<%Response.Write bkColor%>"><a
  141.     href="person.asp?anr=<%Response.Write refMember%>"><font face="Verdana" %><small><%Response.Write rdnMember %></small></font></td>
  142.   </tr>
  143. <% Next %>
  144. </table>
  145. <small><font face="Verdana"><%
  146.   if ( counter > 0 ) then
  147.     Response.Write " Member count: " & counter &" user(s) and group(s)"
  148.   else
  149.     Response.Write "Do not have membership or permission to view"
  150.   end if 
  151.   counter = 0  'Reset counter
  152. %></font></small>
  153.  
  154.  
  155.  
  156. <%
  157.   Set dso = Nothing
  158.   Set o = Nothing
  159.   Set mgr = Nothing
  160. %>
  161. </a>
  162.  
  163.  
  164. <p></p>
  165. <p></p>
  166.  
  167.  
  168. <small><small><font face="Verdana">
  169. <%
  170.   Response.Write "Query was executed in: " & elapse & " second(s)"
  171.   Response.Write "<br>"
  172.   elapse = Timer - t
  173.   Response.Write "Total Time (Execute, Enumeration and Rendering): " & elapse & " second(s)"
  174.  
  175. %>
  176. </font></small></small>
  177.  
  178. </body>
  179. </html>
  180.