ADSI User update page - Help needed

ADSI User update page - Help needed

Post by Robert Hanki » Thu, 07 Feb 2002 20:04:22



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 -
a.. 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 rhan...@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()
%>

 
 
 

1. Use ADSI to update user properties - need authentication.

Hi everyone,
     I hope someone can give me some guidance. I'm trying
to write a VB6 app that will disable a user account and
hide the user from the Exchange Address Book. What my
problem is I need to pass authentication because the app.
will run on a client PC with no Admin. privelages. I have
the code below - it doesn't error but it doesn't work
either. Please help!

    Set dso = GetObject("LDAP:")
    Set obj1 = dso.OpenDSObject "LDAP://dc=domain,
dc=tld", "adminaccount", "password",
ADS_SECURE_AUTHENTICATION)

    Set objUser = GetObject("LDAP://CN=user, OU=orgUnit,
dc=domain, dc=tld")
    objUser.Put "msExchHidefromAddressLists", "True"
    objUser.AccountDisabled = True
    objUser.SetInfo

Thanks and God Bless!

Magnus R

2. Unix/Novell/Sun/SCO - was : Who makes more $$

3. Help: Need ADSI C++ code to get the user objectSid attribute

4. Converting To Money 99 Kimberly Smith Please Answer MVP

5. How can I slect a AD user whit in a asp page and ADSI

6. Protocol analyzer software

7. Web pages to create users using ADSI

8. Modem to support TAPI applications on Win98

9. Enabling users to change their password via web page (ASP/ADSI)

10. Creating WinNT 4.0 User with ADSI in asp page

11. HELP: ADSI in ASP pages (Err 80004005)

12. Need much many help please with queries for users and user groups