<!--#include file="session.inc"-->
<%
' Role Administrator
' modifyowner2.asp
' Copyright (c) Microsoft Corporation 1993-1998. All rights reserved.
' ******************************************************************************
' This page performs an ADO query returing the mailboxes and custom recipients
' matching the search criteria from 'modifyowner.asp'. The results are used to
' build a select list to select the new owner of the role performer DL.
' ******************************************************************************
On Error Resume Next
Response.Expires = 0
%>
<HTML>
<HEAD>
<TITLE>Role Administrator</TITLE>
</HEAD>
<BODY BACKGROUND="back.jpg" BGCOLOR="#FFFF99" TEXT="#000000" LINK="#000000" VLINK="#000000">
<FORM NAME="ModifyOwner" METHOD=POST ACTION="modifyowner3.asp">
<FONT FACE="Arial, Helvetica" SIZE=5><B>Find Role Performer</B></FONT><BR><BR>
<%
Dim objIADs ' stores ADSI mailbox object
Dim strSearchCriteria ' value used to search the directory tree
Dim ADOconn ' ADO connection object
Dim strADOQueryString ' ADO query string
Dim objRS ' recordset object
Dim strSelectStatement ' contains all of the options for the select control
Dim strServer ' Exchange server name
Dim strPerformer ' LDAP path to the role performer
Dim strRole ' LDAP path to the role
Const iCN = 0 ' the first field returned in the recordset objRS
Const iRDN = 1 ' the second field returned in the recordset objRS
Const iADSPATH = 2 ' the third field returned in the recordset objRS
strSelectStatement = ""
strRole = Request.Form("ROLE")
strPerformer = Request.Form("PERFORMER")
strSearchCriteria = Request.Form("UserName")
strServer = Session("Server")
' performs an ADO query through ADSI to find the user's mailbox or custom recipient object
Set ADOconn = CreateObject("ADODB.Connection")
If Err.Number <> 0 Then
displayError "Failed to create ADO object", 1, 1
Else
ADOconn.Provider = "ADSDSOObject"
ADOconn.Open "ADs Provider"
strADOQueryString = "<LDAP://" + strServer + ">;(&(|(objectClass=remote-address)(objectClass=organizationalPerson))(cn=" + strSearchCriteria + "*));cn,rdn,adspath;subtree"
Set objRS = ADOconn.Execute(strADOQueryString)
If Err.Number <> 0 Then
If Err.Number = &H80070044 Then
Response.Write "<FONT FACE='Arial, Helvetica' SIZE=2>Error " + CStr(Hex(Err.Number)) + ": Too many entries match your search criteria!</FONT>"
Err.Clear
Else
displayError "Failed to execute ADO query", 1, 1
End If
Else
If objRS.RecordCount > 0 Then
Response.Write "<FONT FACE='Arial, Helvetica' SIZE=2>Please select the owner from the following list:<BR><BR>"
Response.Write "<SELECT NAME='OWNER'>"
While Not objRS.EOF ' builds the select control of the queried redords
strSelectStatement = strSelectStatement + "<OPTION VALUE=""" + objRS.Fields(iADSPATH).Value + """>" + objRS.Fields(iRDN) + ", " + objRS.Fields(iCN)
objRS.MoveNext
Wend
Response.Write strSelectStatement + "</SELECT>"
Else
Response.Write "<FONT FACE='Arial, Helvetica' SIZE=2>No entries match the search criteria. Try again.</FONT>"
End If
End If
End If
%>
<BR><BR>
<% If objRS.RecordCount > 0 Then %>
<INPUT TYPE="submit" VALUE="Select Role Performer">
<%
End If
%>
<INPUT TYPE="button" VALUE="Try Again" OnClick="window.location='modifyowner.asp?ROLE=<%=encodePath(strRole)%>&PERFORMER=<%=encodePath(strPerformer)%>'">
<%
objRS.Close
%>
<INPUT TYPE="hidden" NAME="PERFORMER" VALUE="<%=strPerformer%>">
<INPUT TYPE="hidden" NAME="ROLE" VALUE="<%=strRole%>">
</FORM>
</BODY>
</HTML>