Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing code from LDAP-Component to normal LDAP

Status
Not open for further replies.

QuinnMal

Technical User
Jul 10, 2006
2
US
Hey. I currently have a secure website where we manage different projects and a manager has the ability to add another manager to their project.

Currently this is done through LDAP IPWORKS! to verify/add the user from our company database. We'd like to eliminate the use of a program and just have it all done in asp code so that we don't have to purchase the program. I have included the 2 asp files we have right now and all their code. If soemone knows how to change the below from relying on IPWORKS to just normal ldap/asp please help me out as I've been trying and can't figure this out.
QuinnMal@gmail.com

File1: addotherman.asp
<%@ LANGUAGE="VBSCRIPT" %>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProjId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<%
'vid=request.querystring("id")
'if len(vid)=0 then vid=0
'mode=request.querystring("mode")
'if len(mode)=0 then mode=0
%>


<p align="center"><font color="#800000" ><strong><u>Enter in the Employee # and last name of the CO-Manager you want to add and then click submit</u></strong></font></p>
<p align="center">&nbsp;</p>
<form method="POST" action="linkotherman.asp">
<p align="left">Employee Number:<br>
<input type="text" name="vnumber" size="20"></p>
<p align="left">Last Name (as listed in Company Database)<br>
<input type="text" name="vlastname" size="20"></p>

<p align="left"><input type="submit" value="Submit" name="B1"></p>
<input type="hidden" name="inid" value="0"><input type="hidden" name="mode" value="0">

</form>
</body>

File 2: linkotherman.asp
<%@ LANGUAGE="VBSCRIPT" %>

<body bgcolor="#CCFFFF">

<%
function pullch( str )
dim plc
plc = instr(1, str, "'")
do while plc>0
str = left(str, plc - 1) & "`" & right(str, len(str)-plc)
plc = instr(plc, str, "'")
loop
pullch = str
end function
%>

<%
dim id, ii, jj
dim arrtype(3), arrval(3)

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "COMPDB"

arrtype(0)="sn"
arrtype(1)="givenName"

empnum=request.form("vnumber")
if len(empnum)=0 then
empnum=0
else
empnum=pullch(empnum)
end if

lastname = request.form("vlastname")
if len(lastname)=0 then
lastname="x"
else
lastname=pullch(lastname)
end if

inid=request.form("inid")
if len(inid)=0 then inid=0

mode=request.form("mode")
if len(mode)=0 then mode=0

mys="select * from tblprojothermans where employeenumber='" & empnum & "' and projid=" & inid & ";"
Set RS = Conn.Execute(MyS)
if rs.eof then 'AA
'ok, not already listed with this project

'now do an LDAP request to check employee number validity
ldaphit=false
Set ldap = Server.CreateObject("IPWorksASP.LDAP")
ldap.ServerName = "ldap.comp.org"
ldap.serverport = 3280
ldap.dn = "o=tesseract,dc=tesct,dc=org,ou=people"
ldap.timeout = 20
ldap.SearchFilter = "uid=" & empnum
ldap.SearchSizeLimit = 1
ldap.searchscope = 2 'subtree
ldap.action = ldapbind
ldap.Search
While ldap.NextResult = 1 '1 is a search result
ldaphit=true
for jj=0 to 1
for ii=0 to (ldap.attrcount-1)
if strcomp(ldap.attrtype(ii), arrtype(jj), vbtextcompare)=0 then
arrval(jj)=ldap.attrvalue(ii)
arrval(jj)=pullch(arrval(jj))
exit for
end if
next
next
Wend
ldaplastname=arrval(0)
ldapfirstname=arrval(1)
if strcomp(arrval(0), lastname, vbtextcompare)=0 then
'hit...store the data
mys="insert into tblprojothermens (projid, empnum, lastname, firstname) values (" & projid & ",'" & empnum & "','" & ldaplastname & "','" & ldapfirstname & "');"
Set RS = Conn.Execute(MyS)
mys="Manager Successfully Added.<BR><BR><a href=editmanframe.asp?id=" & inid & "&mode=2" & " target=_top>Click To Continue</a>"
response.write(mys)
else
'no hit
mys="Manager not found in database. Be sure to enter the employee number correctly, and their lastname exactly as it is found in company database.<BR><BR><a href=editmanframe.asp?id=" & inid & "&mode=2" & " target=_top>Click To Continue</a>"
response.write(mys)
end if
ldap.action = ldapunbind


else 'AA
'do nothing...the pi is already listed as another researcher for this project.
mys="Manager Was Already Linked to this Project.<BR><BR><a href=editmanframe.asp?id=" & inid & "&mode=2" & " target=_top>Click To Continue</a>"
response.write(mys)
end if

%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top