473,770 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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/<DocumentLibrar y>/intro.doc

I have to write a web app which uses Interop.Word.dl l 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 4100
<li******@gmail .com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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/<DocumentLibrar y>/intro.doc

I have to write a web app which uses Interop.Word.dl l 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.Netw orkCredential(" 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.Crea te(<URL>);
wReq.Timeout = 5000;
wReq.Credential s = new NetworkCredenti al("user","pass word","domain") ;
WebResponse wResp = wReq.GetRespons e();
GetStream = wResp.GetRespon seStream();
StreamReader sr = new StreamReader(Ge tStream,true);
FileStream fs = new FileStream(<pat h to output
file>,FileMode. Create,FileAcce ss.Write);
StreamWriter sw = new StreamWriter(fs );

int i = sr.BaseStream.R eadByte();
while(i > -1)
{
sw.BaseStream.W riteByte((Byte) i);
i = sr.BaseStream.R eadByte();
}

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
6581
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 using frames, with thumbnails on the left side of the screen and full-size images displayed on the right. But now I'm sick of frames and I'd like to use javascript to make the whole shebang cleaner and tighter. I'd like to use a table,...
0
1009
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 structure (2 columns), now it has become 3 column structure, badly effecting the web page design. 2-> there are web controls being used as left navigation bar and top navigation, these are not coming and share point default left action items and...
0
944
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 database file it is not working... <add key="Conn" value="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=A\App_Data\Database.mdf"
1
1154
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 application but how i am not able to generate the java code...... If any one provide me some help thanks Nitin
0
842
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 above code, we always get the user name as 'NT AUTHORITY\NETWORK SERVICES'.
2
2710
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 web part definition(dwp) file. Now user select dwp file, web part zone id and page name from drop down and say "Add Web Part". Ideally it should add web part to particular page to that web part zone. I am using...
0
728
by: hitechdeveloper | last post by:
How to bind a sharepoint 2007 list data to webpart developed in asp.net?
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.