Programatically authenticating to website ( Share Point Portal)

  • Thread starter Thread starter listname
  • Start date Start date
L

listname

A SharePoint portal is running at http://sitename/.
When I visit that web site, a dialog box comes up asking
for network domain/userid/password. I provide the details
and the site lets me in. Integrated Windows Auth is ON
for this portal.

There are a few word documents in the site and i can acess
then off url - http://sitename/site/<DocumentLibrary>/intro.doc

I have to write a web app which uses Interop.Word.dll for
creating a word object and reading a file from the above url.
This program has to be deployed in a server and clients are
going access this web app thru browser.

Problem is that since my application is going to run unattended,
when it does Document.Open(), an auth dialog box comes up at
server and there is no one to attend to it. As such visible
is set to false and no one can even see it.

How can I programatically authenticate to SharePoint Portal
to fetch documents from its document library ?

saha
--
 
A SharePoint portal is running at http://sitename/.
When I visit that web site, a dialog box comes up asking
for network domain/userid/password. I provide the details
and the site lets me in. Integrated Windows Auth is ON
for this portal.

There are a few word documents in the site and i can acess
then off url - http://sitename/site/<DocumentLibrary>/intro.doc

I have to write a web app which uses Interop.Word.dll for
creating a word object and reading a file from the above url.
This program has to be deployed in a server and clients are
going access this web app thru browser.

Problem is that since my application is going to run unattended,
when it does Document.Open(), an auth dialog box comes up at
server and there is no one to attend to it. As such visible
is set to false and no one can even see it.

How can I programatically authenticate to SharePoint Portal
to fetch documents from its document library ?

I do a "GET" and a "POST" with the following code to a site that uses
"Basic" authentication:
string url = http://sitename/site/docs/intro.doc
req = (HttpWebRequest)HttpWebRequest.Create(url);
CredentialCache cc = new CredentialCache();
cc.Add(new Uri(url), "Basic", new System.Net.NetworkCredential("username",
"password"));
req.Credentials = cc;

DanB
 
Thanks Dan.

Me now using the following code for NTLM authenticating and fetching
the required document:

Stream GetStream;

WebRequest wReq = WebRequest.Create(<URL>);
wReq.Timeout = 5000;
wReq.Credentials = new NetworkCredential("user","password","domain");
WebResponse wResp = wReq.GetResponse();
GetStream = wResp.GetResponseStream();
StreamReader sr = new StreamReader(GetStream,true);
FileStream fs = new FileStream(<path to output
file>,FileMode.Create,FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);

int i = sr.BaseStream.ReadByte();
while(i > -1)
{
sw.BaseStream.WriteByte((Byte)i);
i = sr.BaseStream.ReadByte();
}

sw.Flush();
fs.Close();
wResp.Close();
MessageBox.Show("Done");
 
Back
Top