-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.asp
156 lines (142 loc) · 5.39 KB
/
search.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!-- #include file="common.asp" -->
<%
Dim dom
Dim ou
Dim cmp
dim strWildcardQuery
dim Query
dim strCell(3)
strSearch = request("searchstr")
strObjectType = request("objectType")
blnAccDisabled = request("accDisabled")
if blnAccDisabled = "true" then blnAccDisabled = true else blnAccDisabled = false
strContainer = strDomainRoot
Set Connect = CreateObject("ADODB.Connection")
Connect.Provider = "ADsDSOObject"
Connect.Open "DS Query"
Query = "<LDAP://" & strDomainRoot & ">;(&"
if len(strSearch) > 0 then Query = Query & "(cn=" & strSearch & "*)"
if blnAccDisabled then
Query = Query & "(&(userAccountControl:1.2.840.113556.1.4.803:=2)"
end if
Select case strObjectType
case "any"
Query = Query & "(|(objectCategory=user)(objectCategory=organizationalUnit)" & _
"(objectCategory=computer)(objectCategory=group)" & _
"(objectCategory=container)(objectCategory=contact)" & _
"(objectCategory=builtinDomain))"
case "user"
Query = Query & "(objectCategory=user)"
case "computer"
Query = Query & "(objectCategory=computer)"
case "contact"
Query = Query & "(&(objectCategory=contact)(objectCategory=person))"
case "group"
Query = Query & "(objectCategory=group)"
case "printer"
Query = Query & "(objectCategory=printQueue)"
End Select
if blnAccDisabled then
Query = Query & ")"
end if
Query = Query & ");distinguishedName,adspath;subtree"
Set RecordSet = Connect.Execute(Query)
%>
<TABLE WIDTH="800px" STYLE="border: 1px solid gray;" CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH="200px" ALIGN="center" STYLE="background: #74AAD7;" VALIGN="top"><IMG SRC="iconSearch.gif"></TD>
<TD WIDTH="600px" ROWSPAN=3 VALIGN="top">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" STYLE="width: 100%" COLS=1 ROWS=2>
<TR>
<TD WIDTH="100%" STYLE="background: #74AAD7; padding: 10px; width: 100%" VALIGN="top">
<SPAN STYLE="font-size: 14pt;">Search Results</SPAN><BR>
<SPAN STYLE="font-size: 10pt;"> </SPAN>
</TD>
</TR>
<TR>
<TD STYLE="padding-top: 5px; padding-bottom: 5px;" VALIGN="top">
<TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=0>
<%
If not(RecordSet.EOF And RecordSet.BOF) Then
While Not RecordSet.EOF
Set obj = GetObject("LDAP://" & ldapEncode(RecordSet.Fields("distinguishedName")))
aryTemp = split(obj.distinguishedName, ",")
strObjName = aryTemp(lbound(aryTemp))
strName = mid(strObjName, instr(strObjName, "=") + 1)
strClass = obj.class
strDescription = trimDesc(obj.Description)
response.write "<TR>" & vbcrlf
select case strClass
case "organizationalUnit", "container", "builtinDomain", "lostAndFound"
strCell(0) = "<A HREF=""index.asp?container=" & MakeURL(obj.distinguishedname) & """>" & strName & "</A>"
strCell(1) = ResolveObjectName(strClass)
strCell(2) = strDescription
case else
select case strClass
case "user"
strCell(0) = "<A HREF=""userdetails.asp?user=" & MakeURL(obj.distinguishedname) & """>" & strName & "</A>"
strCell(1) = ResolveObjectName(strClass)
strCell(2) = strDescription
case "computer"
strCell(0) = "<A HREF=""computerdetails.asp?computer=" & MakeURL(obj.distinguishedname) & """>" & strName & "</A>"
strCell(1) = ResolveObjectName(strClass)
strCell(2) = strDescription
case "group"
strCell(0) = "<A HREF=""groupdetails.asp?group=" & MakeURL(obj.distinguishedname) & """>" & strName & "</A>"
strCell(1) = ResolveObjectName(strClass)
strCell(2) = strDescription
case "printQueue"
aryTemp = split(strName, "-")
strTemp = ""
for count = (lbound(aryTemp) + 1) to ubound(aryTemp)
strTemp = strTemp & aryTemp(count)
if count < ubound(aryTemp) then strTemp = strTemp & "-"
next
strCell(0) = "<A HREF=""printerdetails.asp?printer=" & MakeURL(obj.distinguishedName) & """>" & strTemp & " on " & aryTemp(0) & "</A>"
strCell(1) = ResolveObjectName(strClass)
strCell(2) = strDescription
case else
strCell(0) = strName
strCell(1) = ResolveObjectName(strClass)
strCell(2) = strDescription
end select
end select
select case strClass
case "builtinDomain","computer","container","dnsNode","group", _
"infrastructureUpdate","lostAndFound","organizationalUnit", _
"user", "printQueue", "contact"
response.write "<TD WIDTH=16 VALIGN=""top"" STYLE=""padding-left: 5px;"">" & _
"<IMG SRC=""" & strClass & ".gif"" BORDER=0></TD>"
case else
response.write "<TD WIDTH=16 VALIGN=""top"" STYLE=""padding-left: 5px;"">" & _
"<IMG SRC=""default.gif"" BORDER=0></TD>"
end select
for count = lbound(strCell) to ubound(strCell)
if len(strCell(count)) = 0 then strCell(count) = " "
if count = 0 then
response.write "<TD CLASS=""dataHead"" VALIGN=""top"">" & strCell(count) & "</TD>" & vbCrLf
else
response.write "<TD CLASS=""data"" VALIGN=""top"">" & strCell(count) & "</TD>" & vbCrLf
end if
next
response.write "</TR>" & vbcrlf
RecordSet.MoveNext
WEnd
End If
Set dom = Nothing
Set obj = Nothing
Set cmp = Nothing
%>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD VALIGN="top" WIDTH="200px" STYLE="padding: 10px; background: #74AAD7;">
<%WriteSearch%>
</TD>
</TR>
</TABLE>
</BODY>