Bill Anagnostos
2009-05-04 13:56:08 UTC
I have been assigned to a task to create an email search/lookup tool that
will allow a user to type a few characters of a person's name and retrieve a
list of email addresses from MS Exchange. The preferred language is
JavaScript since the rest of the app is predominantly JavaScript.
In the past we have done this with Lotus Notes (many years ago), but the
email system moved to Outlook and MS Exchange. The client is not sure when
the code below started failed, but they would like to change the code to
access the MS Exchange list.
------------------------
// retrieve addresses from ldap
function GetAddressBook()
{
var conn;
var cmd;
var rs;
var cnt;
var sCompare, sSearch, sCommand;
addrBook = new Array();
addrBookMail = new Array();
// if search is given, add it to ldap search as start of displayName
sSearch = window.opener.TO.AddrSrch.value;
if( sSearch != "" )
sCompare = "(displayName=" + sSearch + "*)";
else
sCompare = "";
conn = new ActiveXObject("ADODB.Connection");
conn.Provider = "ADsDSOObject"; // this is the ADSI-OLEDB provider name
// Set username and password
conn.Properties("User ID") = "CN=ldap,CN=Users,DC=**,DC=****,DC=**,DC=***";
conn.Properties("Password") = "password";
// Open Connection
conn.Open( "Active Directory Provider" );
rs = new ActiveXObject("ADODB.Recordset");
// insert displayName comparison into command
sCommand = "<GC://ipaddress>;(&(mailnickname=*)(l=********)" + sCompare +
");mail,displayName;subtree";
rs.Open( sCommand, conn);
cnt = 0;
while( !rs.EOF )
{
addrBook[cnt] = rs.Fields("displayName").value;
addrBookMail[cnt] = rs.Fields("mail").value;
cnt++;
rs.MoveNext();
}
return cnt;
}
------------------------
Does anyone have some sample code displayng this type of functionality so I
can be led in the correct direction?
I have found the following url which looks like an LDAP search using what
looks like a sql SELCT statement.
http://www.washington.edu/computing/eds/whitepages/jsexample.html
I found this url, but it looks like C#.
http://weblogs.asp.net/whaggard/archive/2007/01/30/how-do-i-access-my-outlook-contacts-from-my-web-application.aspx
will allow a user to type a few characters of a person's name and retrieve a
list of email addresses from MS Exchange. The preferred language is
JavaScript since the rest of the app is predominantly JavaScript.
In the past we have done this with Lotus Notes (many years ago), but the
email system moved to Outlook and MS Exchange. The client is not sure when
the code below started failed, but they would like to change the code to
access the MS Exchange list.
------------------------
// retrieve addresses from ldap
function GetAddressBook()
{
var conn;
var cmd;
var rs;
var cnt;
var sCompare, sSearch, sCommand;
addrBook = new Array();
addrBookMail = new Array();
// if search is given, add it to ldap search as start of displayName
sSearch = window.opener.TO.AddrSrch.value;
if( sSearch != "" )
sCompare = "(displayName=" + sSearch + "*)";
else
sCompare = "";
conn = new ActiveXObject("ADODB.Connection");
conn.Provider = "ADsDSOObject"; // this is the ADSI-OLEDB provider name
// Set username and password
conn.Properties("User ID") = "CN=ldap,CN=Users,DC=**,DC=****,DC=**,DC=***";
conn.Properties("Password") = "password";
// Open Connection
conn.Open( "Active Directory Provider" );
rs = new ActiveXObject("ADODB.Recordset");
// insert displayName comparison into command
sCommand = "<GC://ipaddress>;(&(mailnickname=*)(l=********)" + sCompare +
");mail,displayName;subtree";
rs.Open( sCommand, conn);
cnt = 0;
while( !rs.EOF )
{
addrBook[cnt] = rs.Fields("displayName").value;
addrBookMail[cnt] = rs.Fields("mail").value;
cnt++;
rs.MoveNext();
}
return cnt;
}
------------------------
Does anyone have some sample code displayng this type of functionality so I
can be led in the correct direction?
I have found the following url which looks like an LDAP search using what
looks like a sql SELCT statement.
http://www.washington.edu/computing/eds/whitepages/jsexample.html
I found this url, but it looks like C#.
http://weblogs.asp.net/whaggard/archive/2007/01/30/how-do-i-access-my-outlook-contacts-from-my-web-application.aspx