0
Answer

Problems accessing Exchange Contact List

Ask a question
Jose

Jose

17y
1.9k
1

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