473,800 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to Retrieve an Image File on Another LAN Server

I want to retrieve an image file (TIF) convert it to a bmp file and enable
sizing.

I know how to do the converting & sizing part, and store any atributes to
file location in the webconfig, what I don't know is how to get the image
file.

The only way that I've got it working was to Impersonate a user login at the
other server.

Potential clues...
Image.FromFile
Server.MapPath
URL

Any links or similar are appreciated.
Sep 17 '08 #1
2 1596

You should always know "who" is running the code.

LocalMachine\AS PNET account is typical.
Thus this account would need permissions to read the files on the file
server.

OR you can do impersonation as you see.

Here is some crappy code to ID the account running........ ....
Don't assume, check it when you don't know.
private string FindIIdentity()

{

try

{

//'Dim user As WindowsPrincipa l =
CType(System.Th reading.Thread. CurrentPrincipa l, WindowsPrincipa l)

//'Dim ident As IIdentity = user.Identity

string returnValue = string.Empty;

WindowsIdentity ident = WindowsIdentity .GetCurrent();

returnValue = ident.Name;

try

{

returnValue += " on " + System.Environm ent.MachineName ;

}

catch (Exception ex)

{

Console.WriteLi ne(ex.Message);

}

return returnValue;

}

catch (Exception ex)

{

Conditionals.Tr ace.WriteMessag e(ex.Message);

return "Error Finding Identity";

}

}


"JeffP->" <Je***@discussi ons.microsoft.c omwrote in message
news:E2******** *************** ***********@mic rosoft.com...
>I want to retrieve an image file (TIF) convert it to a bmp file and enable
sizing.

I know how to do the converting & sizing part, and store any atributes to
file location in the webconfig, what I don't know is how to get the image
file.

The only way that I've got it working was to Impersonate a user login at
the
other server.

Potential clues...
Image.FromFile
Server.MapPath
URL

Any links or similar are appreciated.

Sep 17 '08 #2
Here is the code i am using (from ASP.NET) to access shared folder. You
obviously must have User/Password to access that folder.

#region WIN API Declarations
//used in calling WNetAddConnecti on2
[StructLayout(La youtKind.Sequen tial)]
public struct NETRESOURCE
{
public int dwScope;
public int dwType;
public int dwDisplayType;
public int dwUsage;
[MarshalAs(Unman agedType.LPStr)]
public string lpLocalName;
[MarshalAs(Unman agedType.LPStr)]
public string lpRemoteName;
[MarshalAs(Unman agedType.LPStr)]
public string lpComment;
[MarshalAs(Unman agedType.LPStr)]
public string lpProvider;
}
//WIN32API - WNetAddConnecti on2
[DllImport("mpr. dll",
CharSet = System.Runtime. InteropServices .CharSet.Auto)]
private static extern int WNetAddConnecti on2A(
[MarshalAs(Unman agedType.LPArra y)] NETRESOURCE[] lpNetResource,
[MarshalAs(Unman agedType.LPStr)] string lpPassword,
[MarshalAs(Unman agedType.LPStr)] string lpUserName,
int dwFlags);

[DllImport("mpr. dll",
CharSet = System.Runtime. InteropServices .CharSet.Auto)]
private static extern int WNetCancelConne ction2A(
[MarshalAs(Unman agedType.LPStr)] string lpName,
int dwFlags, int fForce);

#endregion

private byte[] GetFSMSFile(str ing sFile)
{
NETRESOURCE[] nr = new NETRESOURCE[1];
nr[0].lpRemoteName = _sFSMSShare;
nr[0].lpLocalName = ""; //mLocalName;
nr[0].dwType = 1; //disk
nr[0].dwDisplayType = 0;
nr[0].dwScope = 0;
nr[0].dwUsage = 0;
nr[0].lpComment = "";
nr[0].lpProvider = "";
int iErr = WNetAddConnecti on2A(nr, _sFSMSShareUser Password,
_sFSMSShareUser , 0);
if (iErr 0)
throw new Exception("Can not connect to FSMS share folder");
FileStream st = null;
try
{
st = new FileStream(_sFS MSShare + "\\" + sFile,
FileMode.Open);
int iLen = (int)st.Length;
byte []b = new byte[iLen];
st.Read(b, 0, iLen);
return b;
}
finally
{
if( st != null )
st.Close();
WNetCancelConne ction2A(_sFSMSS hare, 0, -1);
}
}
George

"sloan" <sl***@ipass.ne twrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
>
You should always know "who" is running the code.

LocalMachine\AS PNET account is typical.
Thus this account would need permissions to read the files on the file
server.

OR you can do impersonation as you see.

Here is some crappy code to ID the account running........ ....
Don't assume, check it when you don't know.
private string FindIIdentity()

{

try

{

//'Dim user As WindowsPrincipa l =
CType(System.Th reading.Thread. CurrentPrincipa l, WindowsPrincipa l)

//'Dim ident As IIdentity = user.Identity

string returnValue = string.Empty;

WindowsIdentity ident = WindowsIdentity .GetCurrent();

returnValue = ident.Name;

try

{

returnValue += " on " + System.Environm ent.MachineName ;

}

catch (Exception ex)

{

Console.WriteLi ne(ex.Message);

}

return returnValue;

}

catch (Exception ex)

{

Conditionals.Tr ace.WriteMessag e(ex.Message);

return "Error Finding Identity";

}

}


"JeffP->" <Je***@discussi ons.microsoft.c omwrote in message
news:E2******** *************** ***********@mic rosoft.com...
>>I want to retrieve an image file (TIF) convert it to a bmp file and enable
sizing.

I know how to do the converting & sizing part, and store any atributes to
file location in the webconfig, what I don't know is how to get the image
file.

The only way that I've got it working was to Impersonate a user login at
the
other server.

Potential clues...
Image.FromFi le
Server.MapPa th
URL

Any links or similar are appreciated.

Sep 17 '08 #3

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

Similar topics

7
3592
by: theonlydrayk | last post by:
the script that show image is : <?php include('dbinfo.inc.php'); mysql_connect($localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT file,filesize,filetype FROM user WHERE id=1;"; $result=mysql_query($query); mysql_close();
3
2050
by: JGBNS via DotNetMonster.com | last post by:
Hi, I am new to this forumand I apologize as i am not a .net programmer but we have a program being developed by a .net programmer. Nowwe have run into an ftp snag and I think it is part ftp and part .net coding. Heres the issue.. We have an image directory full of photos like 200,000 in it, and if you use an ftp client to ftp to the site and then navagate to that file it will try
5
1757
by: news | last post by:
I have a new situation I'm facing and could use a suggestion or two, as I don't seem to be able to think in the abstract very well. We have a local server which holds all of our image files. We have a remote server that runs our public Web server and mySQL database. I need to be able to run a script that will: Read the contents of a dir on the local server and a. make thumbnails of the files in it b. querey the database and pull...
35
2676
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
23
5952
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine on most machines, on some machines I experience this problem: When loading the page a window pops up that asks if I want to open the document show_page.asp. When I click "Open" Interdev pops up and opens up a
8
1776
by: Lloyd Sheen | last post by:
I have a list of JPG's which are found in a SQL Server database. When the page selects a certain piece of data it will refer to the file system (resident on IIS server with a virtual directory) and files contained within a certain folder. I have been trying for quite a while to set the ImageURL of an image control to the correct information. I have googled till my mind hurts but can find nothing to help. I have even tried to copy the...
7
3760
imrosie
by: imrosie | last post by:
Hello, I don't completely understand the working of these functions, but it's been suggested that these will give me what I need. I have a database that pulls in image files (stores the absolute path in database). The image shows up in my subform. The file name is displayed in a form control called 'image description'. The problem is it displays the entire link, such as c:\imageCats\GizmotheCat.jpg (absolute path).... End user cah...
15
2058
by: active | last post by:
Below is a small but complete program that appears to show you can't retrive a Palette from the clipboard. This is true whether the palette is placed on the clipboard by Photoshop or Photoshop or by the below program It lets you place a palette from a file or from a program on the clipboard and allows you to retrieve one from the clipboard. But you'll find the retrieved one is always "Nothing"
6
1730
by: data | last post by:
I searched the internet and saw an old posting which has the same problem I am experiencing. The asp server doesn't recognize the variable I declare publicly in my codebehind class. The variable works fine if I just display in the page "<%=myImageFileName%>", but the server control doesn't recognize it. Is it a miscrosoft bug or did I got the syntax wrong? I am stuck. Please help me. My imageurl is dynamicly generated during page...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
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
10032
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
9085
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...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
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
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
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.