Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADSI User update page - Help needed

2 views
Skip to first unread message

Robert Hankin

unread,
Feb 6, 2002, 6:04:22 AM2/6/02
to
I have created a page to update a users information.  I pass the username into this page and it is supposed to bring back the info to edit.
I used Dreamweaver 4 to do this but I had to manually do a lot of the work with the update command as dreamweaver cannot pull tables out of ADSI.
I can use this page when connecting to a sql server database and it connects fine.  When tailored for ADSI I get the following error -
  • Error Type:
    Response object, ASP 0106 (0x80020005)
    An unhandled data type was encountered.
    /adsi/display_user_to_edit.asp

    I believe the error has something to do with data being split at the highlighted section.  Any help would be appreciated.  I would prefer replies by e-mail to rha...@richmond-foods.plc.uk

 
START OF PAGE
 
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/ADSI.asp" -->
 
<%
' *** Start of MM_Update.  All variables defines here
' *** Edit Operations: declare variables
 
MM_editAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If
 
' boolean to abort record edit
MM_abortEdit = false
 
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
 
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
 
  MM_editConnection = MM_ADSI_STRING
  MM_editTable = "
LDAP://file_print"
  MM_editColumn = "name"
  MM_recordId = "'" + Request.Form("MM_recordId") + "'"
  MM_editRedirectUrl = "
http://www.yahoo.co.uk"
  MM_fieldsStr  = "telephonenumber|value"
  MM_columnsStr = "telephonenumber|none,none,NULL"
 
  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
  Next
 
  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If
 
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
 
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
 
  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "")  Then
 FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
  Next
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
 
  If (Not MM_abortEdit) Then
    ' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close
 
    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If
 
End If
%>
<%
Dim user_from_form
user_from_form =request.form("name")
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_ADSI_STRING
Recordset1.Source = "select sAMAccountName, Description, name, company, title, department, mail, telephoneNumber, otherTelephone, mobile, facsimileTelephoneNumber  From 'LDAP://file_print'  where objectclass='user' and objectcategory='person'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="<%=MM_editAction%>">
  <table width="75%" border="1">
    <tr>
      <td>Name</td>
      <td>
        <input type="text" name="name" value="<%=(Recordset1.Fields.Item("name").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Title</td>
      <td>
        <input type="text" name="title" value="<%=(Recordset1.Fields.Item("title").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Department</td>
      <td>
        <input type="text" name="department" value="<%=(Recordset1.Fields.Item("department").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Site</td>
      <td>
        <input type="text" name="company" value="<%=(Recordset1.Fields.Item("company").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Internal Telephone Number</td>
      <td>
        <input type="text" name="telephoneNumber" value="<%=(Recordset1.Fields.Item("telephoneNumber").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Other Number (Direct Dial)</td>
      <td>
        <input type="text" name="otherTelephoneNumber" value="<%=(Recordset1.Fields.Item("otherTelephone").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Mobile Number</td>
      <td>
        <input type="text" name="mobile" value="<%=(Recordset1.Fields.Item("mobile").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Fax Number</td>
      <td>
        <input type="text" name="facsimileTelephoneNumber" value="<%=(Recordset1.Fields.Item("facsimileTelephoneNumber").Value)%>">
      </td>
    </tr>
    <tr>
      <td>E-mail Address</td>
      <td>
        <input type="text" name="mail" value="<%=(Recordset1.Fields.Item("mail").Value)%>">
      </td>
    </tr>
    <tr>
      <td>Description</td>
      <td>
        <input type="text" name="Description" value="<%=(Recordset1.Fields.Item("Description").Value)%>">
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>
       
      </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
  <input type="hidden" name="MM_update" value="true">
  <input type="hidden" name="MM_recordId" value="<% =Recordset1.Fields.Item("name").Value %>">
</form>
</body>
</html>
<%
Recordset1.Close()
%>

Eric Sassaman [MS]

unread,
Feb 11, 2002, 1:33:54 PM2/11/02
to
Robert, please note that Microsoft is not monitoring this newsgroup any
longer. This newsgroup may be deleted at a future date.
 
We highly recommend you post to microsoft.public.adsi.general as the
best place to discuss Active Directory programming issues. MSDN
managed newsgroup users need to post future questions there as well.
Thanks!

--
Eric Sassaman
Microsoft Support
This posting is provided AS IS with no warranties, and confers no rights.

ispwest.com user

unread,
Feb 19, 2002, 3:15:50 PM2/19/02
to
0 new messages