Getting Global Contacts from Exchange
Exchange Server Forum Index Exchange Server
Discussion forums for Microsoft Exchange Server users.
Microsoft Outlook
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web ExchangeServerHelp.com
Getting Global Contacts from Exchange

 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development
Author Message
Dan Bass
Guest





Posted: Wed Aug 24, 2005 8:59 am    Post subject: Getting Global Contacts from Exchange Reply with quote

Environment
C#, Asp.Net 2.0, Windows 2000 Server


Problem
I'm trying to enumerate all the names in the global contacts on the exchange
server using CDO / ADO / (whatever I can).
In writing an ASP.Net support ticket application, I want to populate the
list of "Who reported this ticket" with names from the global contacts.
An extension of this would then be to allow the user to add a person to the
global contact via the web page, should they not exist in the contacts list.

To start with, I'm writing a basic windows application with one textbox as
the input providing the URL to get the contacts from, and one text box as
the output to put any contacts names I find into. I compile this application
then try to run it on the exchange server, but get an error saying the
"Bookmark is invalid" the first (and every time) MoveNext is called on the
result record set.

I've looked into this error and some articles on the web relate it to
exchange, recommending a machine restart. I've done that the problem
persists. There's no errors with this exchange server with Outlook for
example, so I'm hard pressed to think it's not something with my
application.

Any help or guidance would be appreciated, and yes, I've seen the articles
google gives you on "enumerating contacts with c#" (terrible IMO), and have
read the microsoft articles.


Code
string url = urlTextBox.Text;

ADODB.Connection con = null;
ADODB.Recordset rs = null;

try
{
// create the connection
con = new ADODB.Connection();
con.Provider = "exoledb.datasource";
con.Open(url, "", "", 0);

// build SQL query
string SqlQuery = "SELECT * FROM \"" + url + "\"";

// build the record set object
rs = new ADODB.Recordset();
rs.Open(SqlQuery,
con,
ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic,
0);

// enumarate through the retrieved record set
for (; !rs.EOF; rs.MoveNext()) // <<<--- "Bookmark is invalid"
exception
{
usernamesTextBox.Text +=
rs.Fields["urn:schemas:contacts:givenName"].Value.ToString() +"\r\n";
}

}
catch (Exception ex)
{
MessageBox.Show("OOPS!\r\n------\r\n\r\n" + ex.ToString());
}
finally
{

if (rs != null && rs.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
rs.Close();
if (con != null && con.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
con.Close();
}

Back to top
Dan Bass
Guest





Posted: Wed Aug 24, 2005 2:17 pm    Post subject: Re: Getting Global Contacts from Exchange Reply with quote

MDAC 2.6 appears to have this problem, upgrading the server to 2.8 sorted it
out.



"Dan Bass" <Not Listed> wrote in message
news:ezo0NPIqFHA.904@TK2MSFTNGP09.phx.gbl...
Quote:

Environment
C#, Asp.Net 2.0, Windows 2000 Server


Problem
I'm trying to enumerate all the names in the global contacts on the
exchange server using CDO / ADO / (whatever I can).
In writing an ASP.Net support ticket application, I want to populate the
list of "Who reported this ticket" with names from the global contacts.
An extension of this would then be to allow the user to add a person to
the global contact via the web page, should they not exist in the contacts
list.

To start with, I'm writing a basic windows application with one textbox as
the input providing the URL to get the contacts from, and one text box as
the output to put any contacts names I find into. I compile this
application then try to run it on the exchange server, but get an error
saying the "Bookmark is invalid" the first (and every time) MoveNext is
called on the result record set.

I've looked into this error and some articles on the web relate it to
exchange, recommending a machine restart. I've done that the problem
persists. There's no errors with this exchange server with Outlook for
example, so I'm hard pressed to think it's not something with my
application.

Any help or guidance would be appreciated, and yes, I've seen the articles
google gives you on "enumerating contacts with c#" (terrible IMO), and
have read the microsoft articles.


Code
string url = urlTextBox.Text;

ADODB.Connection con = null;
ADODB.Recordset rs = null;

try
{
// create the connection
con = new ADODB.Connection();
con.Provider = "exoledb.datasource";
con.Open(url, "", "", 0);

// build SQL query
string SqlQuery = "SELECT * FROM \"" + url + "\"";

// build the record set object
rs = new ADODB.Recordset();
rs.Open(SqlQuery,
con,
ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic,
0);

// enumarate through the retrieved record set
for (; !rs.EOF; rs.MoveNext()) // <<<--- "Bookmark is invalid"
exception
{
usernamesTextBox.Text +=
rs.Fields["urn:schemas:contacts:givenName"].Value.ToString() +"\r\n";
}

}
catch (Exception ex)
{
MessageBox.Show("OOPS!\r\n------\r\n\r\n" + ex.ToString());
}
finally
{

if (rs != null && rs.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
rs.Close();
if (con != null && con.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
con.Close();
}

Back to top
 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server Dedicated Servers
Contact Us
New Topics Powered by phpBB