473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Programatically authenticating to website ( Share Point Portal)

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
--

Nov 17 '05 #1
2 4085
<li******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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
Nov 17 '05 #2
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");

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Joseph Ellis | last post by:
Hello all. I have a family website that I have been maintaining for the past year and a half or so. It includes a photo album that has grown quite large. So far I've displayed the photo album...
0
by: Prashant | last post by:
Hi, I am facing a strange problem post upgradation to SP1. Following problems I find in my SP Site, that was working perfectly all right before that. 1-> Web Part Page were having two web part...
0
by: micky | last post by:
there are three wesite called A,B,C these are just share 1 database file called database.mdf in app_data it's that i wanna make design. i don't want to use sql server machine. just use...
1
by: Amam | last post by:
I am not able to use web services of the share point server in java application.I found that axia is used to convert the web services into the code and you can use that code in ur client...
0
by: prem | last post by:
We are writing a code for EventSink, in the EventSink code, we need to get the user name, the code we use to get the current user name is: Sharepointweb.currentUser.Name when we use the...
2
by: =?Utf-8?B?U2FjaGluRw==?= | last post by:
I am working on share point web part development. As a client requirement we have to generate our own web part gallery, so I prefer to write one user control, and in that user control I display all...
0
by: hitechdeveloper | last post by:
How to bind a sharepoint 2007 list data to webpart developed in asp.net?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.