Click to See Complete Forum and Search --> : Problems accessing Exchange Contact List


JoseMadrid
05-24-2007, 06:29 AM
Hi all,

I’ve to develop an user control to search contacts in LDAP and in the personal contacts folder of the Microsoft Exchange Server.

The problem comes when I want to access the contact list. In my local machine, this code goes perfectly.

MyCredentialCache = new System.Net.CredentialCache();

MyCredentialCache.Add(new System.Uri(strContactURI), "NTLM", (NetworkCredential)System.Net.CredentialCache.DefaultCredentials);

Request=(System.Net.HttpWebRequest)HttpWebRequest.Create(strContactURI);
Request.Credentials = MyCredentialCache;
return formatData(Execute ("SEARCH", Request, (string)strQuery));

But when I publish my web app. in the server, I obtain the next error:

The remote server returned an error: (401) Unauthorized.

In IIS’s virtual directory, Properties, Directory Security only Integrated Windows Authentication check is checked (of course, Anonymous Access check is not checked).

Notice that next code goes ok in the web server

MyCredentialCache = new System.Net.CredentialCache();

MyCredentialCache.Add(new System.Uri(strContactURI),"NTLM",
new System.Net.NetworkCredential("user", "pwd", "domain"));

Request=(System.Net.HttpWebRequest)HttpWebRequest.Create(strContactURI);
Request.Credentials = MyCredentialCache;
return formatData(Execute ("SEARCH", Request, (string)strQuery));

It’s obvious I can’t use this code… I’ve the user and the domain but I have not the password of the users.

Can some body help me??? Thnx in advanced. And sorry for my English :(

Ribeyed
05-24-2007, 12:24 PM
hi,
here is a example in VB.net
http://www.codeproject.com/vb/net/LDAP_Using_VBnet.asp

JoseMadrid
05-28-2007, 03:37 AM
Thanks for your answer Ribeyed, but the problem comes when I try to access the exchange server to retrieve the personal contacts of the user.

Any idea???

Ribeyed
05-28-2007, 07:02 AM
Hi,
looking through you're code it differs from the example i gave you. It imports the System.DirectoryServices class but your code dosn't.
In the example there is no need for the passwords to be known but in your code you have to supply the password. maybe you are taken the wrong approach. Have a try with the code from the example i gave you.