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>