call vbscript procedure from onclick event of button

Author Message
largo

  • Total Posts : 19
  • Scores: 0
  • Reward points : 0
  • Joined: 5/15/2008
  • Status: offline
call vbscript procedure from onclick event of button Monday, April 04, 2011 7:35 PM (permalink)
0
hello

i created to pages named:

myuser.asp - user input detailes to create new active directory user
createuser.asp - get the input with get method and create the user with the input

everything is going great, the thing i want to check if the full name (displayname) the user input
all ready exist in active directory and warn the user and not redirect to the other page,
if the user not exist continune normal.

my question how can i call or combine the function i wrote in the code attached to do all the checking, or if you have another idea it welcome all so.
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>create user</title>
</head>

<body>
<h1 style="color:blue">¿¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿¿¿ ¿¿¿¿¿ ¿¿¿¿¿.</h1>
<br/>
<form  method="get" action="createuser.asp">
<table>
<tr>
<td>enter full name</td>
<td><input type="text" name="strdisplayname"/></td>
</tr>
<tr>
<td>user to copy from</td>
<td><input type="text" name="strusertocopy"/></td>
</tr>
<tr>
<td>user to send the detailes in email</td>
<td><input type="text" name="strsendto"/></td>
</tr>
</table>
<br/>
<div style="text-align:center">
<input type="submit" value="submit" onclick="checkuserexist(strdisplayname)"/>
</div>
</form>
<%
Function CheckUserExist(UserName)
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://RootDSE")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
objCommand.CommandText = _
     "SELECT displayName FROM 'LDAP://" & objRootDSE.get("defaultNamingContext") & "' WHERE objectCategory='user' " & _
        "AND displayName = '" & UserName & "'"

Set objRecordSet = objCommand.Execute

If objRecordset.RecordCount = 0 Then
    'redirect with the input from the user
    response.write("not exist")
Else
    response.write("exist")
End If
objConnection.Close
End Function
%>
</body>

</html> 

 
#1
    webber123456

    • Total Posts : 58
    • Scores: 0
    • Reward points : 0
    • Joined: 9/20/2007
    • Status: offline
    Re:call vbscript procedure from onclick event of button Thursday, April 07, 2011 7:10 PM (permalink)
    0
    for client side code to interact with server-side code you must use something like AJAX.
     
    google for
     
    ASP AJAX examples
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9