Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Monday, March 26, 2012

Performance tweak

Hello all,
I've been doing some performance analysis on our app, and I've discovered
that the below code is quite a bottle neck:
this.OnFillParameters(selectCommand);
SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);
try
{
selectAdapter.Fill(resultsDataSet);
....
Does anyone have any suggestions/pointers on how this could be improved.
Any comments welcomed.
Thanks,
JYhi,
sorry what do you mean by bottle neck?
Jon wrote:
> Hello all,
> I've been doing some performance analysis on our app, and I've discovered
> that the below code is quite a bottle neck:
> this.OnFillParameters(selectCommand);
> SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);
> try
> {
> selectAdapter.Fill(resultsDataSet);
> ....
>
> Does anyone have any suggestions/pointers on how this could be improved.
> Any comments welcomed.
> Thanks,
> JY
Hi,
My apologies, I shouldn't use local terms on international forums! :)
By bottle next I mean an area of the application that is the slowest.
Thanks,
Jon
"Varangian" wrote:

> hi,
> sorry what do you mean by bottle neck?
>
> Jon wrote:
>
Hi Jon,
BottleNeck is a common technical term, so don't sweat it!
You've got some pretty simple code there. How many records does it fetch?
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
If the Truth hurts, wear it.
"Jon" <Jon@.discussions.microsoft.com> wrote in message
news:23D239C3-8A52-45ED-B123-951CB9881745@.microsoft.com...
> Hi,
> My apologies, I shouldn't use local terms on international forums! :)
> By bottle next I mean an area of the application that is the slowest.
> Thanks,
> Jon
> "Varangian" wrote:
>
Unless you're calling that code inside a loop, I can't see that it's
going to cause performance problems. You can always use a SqlDataReader
directly if you want the fastest access to your data but, in all
likelyhood, the performance problem lies with your database query.
Jon wrote:
> Hi,
> My apologies, I shouldn't use local terms on international forums! :)
> By bottle next I mean an area of the application that is the slowest.
> Thanks,
> Jon
> "Varangian" wrote:
>
Hi Kevin and thanks for the reply.
The SP returns varying amounts of data, but even for say 100 records, it's
slow. I do know that the Database and SP's need to be looked at, for example
,
if 1 SP returns 10 rows, it then fires off 10 SP's passing in the values fro
m
the first SP (you get the idea!).
But I'd prefer to start with the C# code, as it's less of a beast, and more
my domain. The DB has other issues, I'm really just trying to quel the fire
so to speak.
I was thinking of using the MS DAB, not the June 2005 release. Would that be
better? I'm really just looking for some advice / help.
Thanks again,
Jon
"Kevin Spencer" wrote:

> Hi Jon,
> BottleNeck is a common technical term, so don't sweat it!
> You've got some pretty simple code there. How many records does it fetch?
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> Software Composer
> http://unclechutney.blogspot.com
> If the Truth hurts, wear it.
> "Jon" <Jon@.discussions.microsoft.com> wrote in message
> news:23D239C3-8A52-45ED-B123-951CB9881745@.microsoft.com...
>
>
The first thing you should do, if you can, is look at the execution of
your procedure in Sql Query Analyzer and see how much of the time spent
in that block is accounted for by SQL server. Without knowing the
numbers, you can't optimise usefully.
There's not much code there to optimise. It isn't teh uber-leet h4x0r
fastest way of doing DB access, but the difference between that and
other methods is going to be minimal.
If that code is running slowly, I would place hard-earned money on the
issue being time spent inside Sql server. I don't honestly think you
will make any measurable dent on your performance problem by tweaking
that code.
Of course, if I'm wrong, I want to know about it, so let people know
what you find out in any case.
-- Bob Gregory
Unvalued Professional.
Jon wrote:
> Hi Kevin and thanks for the reply.
> The SP returns varying amounts of data, but even for say 100 records, it's
> slow. I do know that the Database and SP's need to be looked at, for examp
le,
> if 1 SP returns 10 rows, it then fires off 10 SP's passing in the values f
rom
> the first SP (you get the idea!).
> But I'd prefer to start with the C# code, as it's less of a beast, and mor
e
> my domain. The DB has other issues, I'm really just trying to quel the fir
e
> so to speak.
> I was thinking of using the MS DAB, not the June 2005 release. Would that
be
> better? I'm really just looking for some advice / help.
> Thanks again,
> Jon
> "Kevin Spencer" wrote:
>
Hi Jon,
You're correct about optimizing the stored procedures, which I can't really
say anything about. As for your code, yes, it could be optimized, depending
upon your requirements. For example, it sounds like you're simply fetching a
single set of data, or a single DataTable. But you're using a DataSet, which
is a rather large and complex class that mimics a database in many ways,
holding numerous DataTables, handling relationships, etc. One optimization
would be to simply use a DataTable with a SqlDataReader. The SqlDataReader
is a very fast little class (which is actually used by a SqlDataAdapter to
do the work that it does in filling DataTables and DataSets). You can fetch
the data with the SqlDataReader, and then pass it as a parameter to the
DataTable.Load method. See
http://msdn2.microsoft.com/en-us/li...table.load.aspx for
more details, and good luck!
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
If the Truth hurts, wear it.
"Jon" <Jon@.discussions.microsoft.com> wrote in message
news:0520A1D8-956E-44B1-8ACD-55DC3F6EC783@.microsoft.com...
> Hi Kevin and thanks for the reply.
> The SP returns varying amounts of data, but even for say 100 records, it's
> slow. I do know that the Database and SP's need to be looked at, for
> example,
> if 1 SP returns 10 rows, it then fires off 10 SP's passing in the values
> from
> the first SP (you get the idea!).
> But I'd prefer to start with the C# code, as it's less of a beast, and
> more
> my domain. The DB has other issues, I'm really just trying to quel the
> fire
> so to speak.
> I was thinking of using the MS DAB, not the June 2005 release. Would that
> be
> better? I'm really just looking for some advice / help.
> Thanks again,
> Jon
> "Kevin Spencer" wrote:
>

Performance tweak

Hello all,

I've been doing some performance analysis on our app, and I've discovered
that the below code is quite a bottle neck:

this.OnFillParameters(selectCommand);

SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);

try
{
selectAdapter.Fill(resultsDataSet);
.....

Does anyone have any suggestions/pointers on how this could be improved.

Any comments welcomed.

Thanks,

JYhi,

sorry what do you mean by bottle neck?

Jon wrote:

Quote:

Originally Posted by

Hello all,
I've been doing some performance analysis on our app, and I've discovered
that the below code is quite a bottle neck:
this.OnFillParameters(selectCommand);
SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);
try
{
selectAdapter.Fill(resultsDataSet);
....
>
Does anyone have any suggestions/pointers on how this could be improved.
Any comments welcomed.
Thanks,
JY


Hi,

My apologies, I shouldn't use local terms on international forums! :)

By bottle next I mean an area of the application that is the slowest.

Thanks,

Jon

"Varangian" wrote:

Quote:

Originally Posted by

hi,
>
sorry what do you mean by bottle neck?
>
>
Jon wrote:

Quote:

Originally Posted by

Hello all,

I've been doing some performance analysis on our app, and I've discovered
that the below code is quite a bottle neck:

this.OnFillParameters(selectCommand);

SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);

try
{
selectAdapter.Fill(resultsDataSet);
....

Does anyone have any suggestions/pointers on how this could be improved.

Any comments welcomed.

Thanks,

JY


>
>


Hi Jon,

BottleNeck is a common technical term, so don't sweat it!

You've got some pretty simple code there. How many records does it fetch?

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
If the Truth hurts, wear it.

"Jon" <Jon@dotnet.itags.org.discussions.microsoft.comwrote in message
news:23D239C3-8A52-45ED-B123-951CB9881745@dotnet.itags.org.microsoft.com...

Quote:

Originally Posted by

Hi,
>
My apologies, I shouldn't use local terms on international forums! :)
>
By bottle next I mean an area of the application that is the slowest.
>
Thanks,
>
Jon
>
"Varangian" wrote:
>

Quote:

Originally Posted by

>hi,
>>
>sorry what do you mean by bottle neck?
>>
>>
>Jon wrote:

Quote:

Originally Posted by

Hello all,
>
I've been doing some performance analysis on our app, and I've
discovered
that the below code is quite a bottle neck:
>
this.OnFillParameters(selectCommand);
>
SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);
>
try
{
selectAdapter.Fill(resultsDataSet);
....
>
>
Does anyone have any suggestions/pointers on how this could be
improved.
>
Any comments welcomed.
>
Thanks,
>
JY


>>
>>


Unless you're calling that code inside a loop, I can't see that it's
going to cause performance problems. You can always use a SqlDataReader
directly if you want the fastest access to your data but, in all
likelyhood, the performance problem lies with your database query.

Jon wrote:

Quote:

Originally Posted by

Hi,
>
My apologies, I shouldn't use local terms on international forums! :)
>
By bottle next I mean an area of the application that is the slowest.
>
Thanks,
>
Jon
>
"Varangian" wrote:
>

Quote:

Originally Posted by

hi,

sorry what do you mean by bottle neck?

Jon wrote:

Quote:

Originally Posted by

Hello all,
>
I've been doing some performance analysis on our app, and I've discovered
that the below code is quite a bottle neck:
>
this.OnFillParameters(selectCommand);
>
SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);
>
try
{
selectAdapter.Fill(resultsDataSet);
....
>
>
Does anyone have any suggestions/pointers on how this could be improved.
>
Any comments welcomed.
>
Thanks,
>
JY



Hi Kevin and thanks for the reply.

The SP returns varying amounts of data, but even for say 100 records, it's
slow. I do know that the Database and SP's need to be looked at, for example,
if 1 SP returns 10 rows, it then fires off 10 SP's passing in the values from
the first SP (you get the idea!).

But I'd prefer to start with the C# code, as it's less of a beast, and more
my domain. The DB has other issues, I'm really just trying to quel the fire
so to speak.

I was thinking of using the MS DAB, not the June 2005 release. Would that be
better? I'm really just looking for some advice / help.

Thanks again,

Jon

"Kevin Spencer" wrote:

Quote:

Originally Posted by

Hi Jon,
>
BottleNeck is a common technical term, so don't sweat it!
>
You've got some pretty simple code there. How many records does it fetch?
>
--
HTH,
>
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
>
If the Truth hurts, wear it.
>
"Jon" <Jon@dotnet.itags.org.discussions.microsoft.comwrote in message
news:23D239C3-8A52-45ED-B123-951CB9881745@dotnet.itags.org.microsoft.com...

Quote:

Originally Posted by

Hi,

My apologies, I shouldn't use local terms on international forums! :)

By bottle next I mean an area of the application that is the slowest.

Thanks,

Jon

"Varangian" wrote:

Quote:

Originally Posted by

hi,
>
sorry what do you mean by bottle neck?
>
>
Jon wrote:
Hello all,

I've been doing some performance analysis on our app, and I've
discovered
that the below code is quite a bottle neck:

this.OnFillParameters(selectCommand);

SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);

try
{
selectAdapter.Fill(resultsDataSet);
....

Does anyone have any suggestions/pointers on how this could be
improved.

Any comments welcomed.

Thanks,

JY
>
>


>
>
>


The first thing you should do, if you can, is look at the execution of
your procedure in Sql Query Analyzer and see how much of the time spent
in that block is accounted for by SQL server. Without knowing the
numbers, you can't optimise usefully.

There's not much code there to optimise. It isn't teh uber-leet h4x0r
fastest way of doing DB access, but the difference between that and
other methods is going to be minimal.

If that code is running slowly, I would place hard-earned money on the
issue being time spent inside Sql server. I don't honestly think you
will make any measurable dent on your performance problem by tweaking
that code.

Of course, if I'm wrong, I want to know about it, so let people know
what you find out in any case.

-- Bob Gregory
Unvalued Professional.

Jon wrote:

Quote:

Originally Posted by

Hi Kevin and thanks for the reply.
>
The SP returns varying amounts of data, but even for say 100 records, it's
slow. I do know that the Database and SP's need to be looked at, for example,
if 1 SP returns 10 rows, it then fires off 10 SP's passing in the values from
the first SP (you get the idea!).
>
But I'd prefer to start with the C# code, as it's less of a beast, and more
my domain. The DB has other issues, I'm really just trying to quel the fire
so to speak.
>
I was thinking of using the MS DAB, not the June 2005 release. Would that be
better? I'm really just looking for some advice / help.
>
Thanks again,
>
Jon
>
"Kevin Spencer" wrote:
>

Quote:

Originally Posted by

Hi Jon,

BottleNeck is a common technical term, so don't sweat it!

You've got some pretty simple code there. How many records does it fetch?

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
If the Truth hurts, wear it.

"Jon" <Jon@dotnet.itags.org.discussions.microsoft.comwrote in message
news:23D239C3-8A52-45ED-B123-951CB9881745@dotnet.itags.org.microsoft.com...

Quote:

Originally Posted by

Hi,
>
My apologies, I shouldn't use local terms on international forums! :)
>
By bottle next I mean an area of the application that is the slowest.
>
Thanks,
>
Jon
>
"Varangian" wrote:
>
>hi,
>>
>sorry what do you mean by bottle neck?
>>
>>
>Jon wrote:
Hello all,
>
I've been doing some performance analysis on our app, and I've
discovered
that the below code is quite a bottle neck:
>
this.OnFillParameters(selectCommand);
>
SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);
>
try
{
selectAdapter.Fill(resultsDataSet);
....
>
>
Does anyone have any suggestions/pointers on how this could be
improved.
>
Any comments welcomed.
>
Thanks,
>
JY
>>
>>



Hi Jon,

You're correct about optimizing the stored procedures, which I can't really
say anything about. As for your code, yes, it could be optimized, depending
upon your requirements. For example, it sounds like you're simply fetching a
single set of data, or a single DataTable. But you're using a DataSet, which
is a rather large and complex class that mimics a database in many ways,
holding numerous DataTables, handling relationships, etc. One optimization
would be to simply use a DataTable with a SqlDataReader. The SqlDataReader
is a very fast little class (which is actually used by a SqlDataAdapter to
do the work that it does in filling DataTables and DataSets). You can fetch
the data with the SqlDataReader, and then pass it as a parameter to the
DataTable.Load method. See
http://msdn2.microsoft.com/en-us/li...table.load.aspx for
more details, and good luck!

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
If the Truth hurts, wear it.

"Jon" <Jon@dotnet.itags.org.discussions.microsoft.comwrote in message
news:0520A1D8-956E-44B1-8ACD-55DC3F6EC783@dotnet.itags.org.microsoft.com...

Quote:

Originally Posted by

Hi Kevin and thanks for the reply.
>
The SP returns varying amounts of data, but even for say 100 records, it's
slow. I do know that the Database and SP's need to be looked at, for
example,
if 1 SP returns 10 rows, it then fires off 10 SP's passing in the values
from
the first SP (you get the idea!).
>
But I'd prefer to start with the C# code, as it's less of a beast, and
more
my domain. The DB has other issues, I'm really just trying to quel the
fire
so to speak.
>
I was thinking of using the MS DAB, not the June 2005 release. Would that
be
better? I'm really just looking for some advice / help.
>
Thanks again,
>
Jon
>
"Kevin Spencer" wrote:
>

Quote:

Originally Posted by

>Hi Jon,
>>
>BottleNeck is a common technical term, so don't sweat it!
>>
>You've got some pretty simple code there. How many records does it fetch?
>>
>--
>HTH,
>>
>Kevin Spencer
>Microsoft MVP
>Software Composer
>http://unclechutney.blogspot.com
>>
>If the Truth hurts, wear it.
>>
>"Jon" <Jon@dotnet.itags.org.discussions.microsoft.comwrote in message
>news:23D239C3-8A52-45ED-B123-951CB9881745@dotnet.itags.org.microsoft.com...

Quote:

Originally Posted by

Hi,
>
My apologies, I shouldn't use local terms on international forums! :)
>
By bottle next I mean an area of the application that is the slowest.
>
Thanks,
>
Jon
>
"Varangian" wrote:
>
>hi,
>>
>sorry what do you mean by bottle neck?
>>
>>
>Jon wrote:
Hello all,
>
I've been doing some performance analysis on our app, and I've
discovered
that the below code is quite a bottle neck:
>
this.OnFillParameters(selectCommand);
>
SqlDataAdapter selectAdapter = new SqlDataAdapter(selectCommand);
>
try
{
selectAdapter.Fill(resultsDataSet);
....
>
>
Does anyone have any suggestions/pointers on how this could be
improved.
>
Any comments welcomed.
>
Thanks,
>
JY
>>
>>


>>
>>
>>

Saturday, March 24, 2012

Permission denied problem. please help me

Hi All,

I am trying to download the file from network machine (under same domain). I
am using below link page code to impersonate.

http://www.netomatix.com/ImpersonateUser.aspx

I can able to impersonate the user, when i try to download the file, its
says "unknown user name and password". I given full permission to domain
user. but the same time when i provied the user name and deails on webconfig
file like below, its allowing me to download.

<identity impersonate="true" userName="mydomain\bala" password="password" /
I dont know where the problem is. Can anyone please give me idea to resolve
this.
I am trying to fix this problem past 3 days.

below is the complete code i am using...

i am getting error on response.writefile. This is the error message

Logon failure: unknown user name or bad password.
exception Details: System.IO.IOException: Logon failure: unknown user name
or bad password.

code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim impContext As WindowsImpersonationContext = Nothing
Try
impContext = NetworkSecurity.ImpersonateUser("mydomain",
"bala", "password", LogonType.LOGON32_LOGON_NETWORK,
LogonProvider.LOGON32_PROVIDER_DEFAULT)
Catch ex As ApplicationException
impContext.Undo()
Response.Write(ex.Message)
End Try
If Not (Nothing Is impContext) Then
Try
Catch ex As Exception
Response.Write(ex.Message)
Finally
impContext.Undo()
If Page.IsPostBack Then
Dim spath As String
spath = "\\laptop02\temp\test.pdf"
'DownloadFile(spath, True)
Dim path1 As String = spath
Dim name As String = Path.GetFileName(path1)

Dim ext As String = Path.GetExtension(path1)
Dim type As String = ""
If Not (ext Is Nothing) Then
Select Case ext.ToLower
Case ".htm", ".html"
type = "text/HTML"
' break
Case ".txt"
type = "text/plain"
' break
Case ".doc", ".rtf"
type = "Application/msword"
' break
Case ".pdf"
type = "Application/pdf"
End Select
End If
'If forceDownload Then
Response.AppendHeader("content-disposition",
"attachment; filename = " & name)
'End If
If Not (type = "") Then
Response.ContentType = type
End If
Response.WriteFile(path1)
Response.End()

End If
End Try
End If
End Sub

thanks
balaImpersonation only allows access to local resources as the user who's using
your site. You want delegation which will allow off-host access as the user
who has authenticated in the browser. In essence it means you need to enable
this in AD for the machine that's running your webserver. Check out this
for more info:

http://pluralsite.com/wiki/default...Delegation.html

-Brock
DevelopMentor
http://staff.develop.com/ballen

> Hi All,
> I am trying to download the file from network machine (under same
> domain). I am using below link page code to impersonate.
> http://www.netomatix.com/ImpersonateUser.aspx
> I can able to impersonate the user, when i try to download the file,
> its says "unknown user name and password". I given full permission to
> domain user. but the same time when i provied the user name and deails
> on webconfig file like below, its allowing me to download.
> <identity impersonate="true" userName="mydomain\bala"
> password="password" />
> I dont know where the problem is. Can anyone please give me idea to
> resolve this. I am trying to fix this problem past 3 days.
> below is the complete code i am using...
> i am getting error on response.writefile. This is the error message
> Logon failure: unknown user name or bad password. exception Details:
> System.IO.IOException: Logon failure: unknown user name or bad
> password.
> code:
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim impContext As WindowsImpersonationContext = Nothing
> Try
> impContext =
> NetworkSecurity.ImpersonateUser("mydomain",
> "bala", "password", LogonType.LOGON32_LOGON_NETWORK,
> LogonProvider.LOGON32_PROVIDER_DEFAULT)
> Catch ex As ApplicationException
> impContext.Undo()
> Response.Write(ex.Message)
> End Try
> If Not (Nothing Is impContext) Then
> Try
> Catch ex As Exception
> Response.Write(ex.Message)
> Finally
> impContext.Undo()
> If Page.IsPostBack Then
> Dim spath As String
> spath = "\\laptop02\temp\test.pdf"
> 'DownloadFile(spath, True)
> Dim path1 As String = spath
> Dim name As String = Path.GetFileName(path1)
> Dim ext As String = Path.GetExtension(path1)
> Dim type As String = ""
> If Not (ext Is Nothing) Then
> Select Case ext.ToLower
> Case ".htm", ".html"
> type = "text/HTML"
> ' break
> Case ".txt"
> type = "text/plain"
> ' break
> Case ".doc", ".rtf"
> type = "Application/msword"
> ' break
> Case ".pdf"
> type = "Application/pdf"
> End Select
> End If
> 'If forceDownload Then
> Response.AppendHeader("content-disposition",
> "attachment; filename = " & name)
> 'End If
> If Not (type = "") Then
> Response.ContentType = type
> End If
> Response.WriteFile(path1)
> Response.End()
> End If
> End Try
> End If
> End Sub
> thanks
> bala
Hi Brock,

Thanks for the reply. The user name which i am using is under the same
DOMAIN.

Are you mentioning the same domain user or local user for that machine?

Thanks
bala

"Brock Allen" wrote:

> Impersonation only allows access to local resources as the user who's using
> your site. You want delegation which will allow off-host access as the user
> who has authenticated in the browser. In essence it means you need to enable
> this in AD for the machine that's running your webserver. Check out this
> for more info:
> http://pluralsite.com/wiki/default...Delegation.html
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
> > Hi All,
> > I am trying to download the file from network machine (under same
> > domain). I am using below link page code to impersonate.
> > http://www.netomatix.com/ImpersonateUser.aspx
> > I can able to impersonate the user, when i try to download the file,
> > its says "unknown user name and password". I given full permission to
> > domain user. but the same time when i provied the user name and deails
> > on webconfig file like below, its allowing me to download.
> > <identity impersonate="true" userName="mydomain\bala"
> > password="password" />
> > I dont know where the problem is. Can anyone please give me idea to
> > resolve this. I am trying to fix this problem past 3 days.
> > below is the complete code i am using...
> > i am getting error on response.writefile. This is the error message
> > Logon failure: unknown user name or bad password. exception Details:
> > System.IO.IOException: Logon failure: unknown user name or bad
> > password.
> > code:
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > Dim impContext As WindowsImpersonationContext = Nothing
> > Try
> > impContext =
> > NetworkSecurity.ImpersonateUser("mydomain",
> > "bala", "password", LogonType.LOGON32_LOGON_NETWORK,
> > LogonProvider.LOGON32_PROVIDER_DEFAULT)
> > Catch ex As ApplicationException
> > impContext.Undo()
> > Response.Write(ex.Message)
> > End Try
> > If Not (Nothing Is impContext) Then
> > Try
> > Catch ex As Exception
> > Response.Write(ex.Message)
> > Finally
> > impContext.Undo()
> > If Page.IsPostBack Then
> > Dim spath As String
> > spath = "\\laptop02\temp\test.pdf"
> > 'DownloadFile(spath, True)
> > Dim path1 As String = spath
> > Dim name As String = Path.GetFileName(path1)
> > Dim ext As String = Path.GetExtension(path1)
> > Dim type As String = ""
> > If Not (ext Is Nothing) Then
> > Select Case ext.ToLower
> > Case ".htm", ".html"
> > type = "text/HTML"
> > ' break
> > Case ".txt"
> > type = "text/plain"
> > ' break
> > Case ".doc", ".rtf"
> > type = "Application/msword"
> > ' break
> > Case ".pdf"
> > type = "Application/pdf"
> > End Select
> > End If
> > 'If forceDownload Then
> > Response.AppendHeader("content-disposition",
> > "attachment; filename = " & name)
> > 'End If
> > If Not (type = "") Then
> > Response.ContentType = type
> > End If
> > Response.WriteFile(path1)
> > Response.End()
> > End If
> > End Try
> > End If
> > End Sub
> > thanks
> > bala
>
>
> Thanks for the reply. The user name which i am using is under the same
> DOMAIN.

Ok, that shouldn't matter with delegation.

> Are you mentioning the same domain user or local user for that
> machine?

For delegation you'll have to be using kerb. The username doesn't matter,
the important thing is to configure the server to be trusted for delegation.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi Brock,

Using this below link code i can able to impersonate the user on my domain
user account. From my locl machine IIS i can able to download the other
machine file, like below path.
("AnotherNetworkMachine\temp\ss.pdf")

But when i place this code my server, the impersonate is doing succuss, but
its taking too much time to download and finally it says page cannot be
displayed error.

any idea.

bala

http://west-wind.com/weblog/posts/1572.aspx

"Brock Allen" wrote:

> > Thanks for the reply. The user name which i am using is under the same
> > DOMAIN.
> Ok, that shouldn't matter with delegation.
> > Are you mentioning the same domain user or local user for that
> > machine?
> For delegation you'll have to be using kerb. The username doesn't matter,
> the important thing is to configure the server to be trusted for delegation.
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
Hi Brock,

If i create a local account on webserver and same username and password for
network machine to local, In this point can i able to download the file?

thanks
bala

"Brock Allen" wrote:

> > Thanks for the reply. The user name which i am using is under the same
> > DOMAIN.
> Ok, that shouldn't matter with delegation.
> > Are you mentioning the same domain user or local user for that
> > machine?
> For delegation you'll have to be using kerb. The username doesn't matter,
> the important thing is to configure the server to be trusted for delegation.
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
sorry. when i run the application on same domain its download the file. but
from outside i am getting error. so that wont work.

bala

"Bala" wrote:

> Hi Brock,
> Using this below link code i can able to impersonate the user on my domain
> user account. From my locl machine IIS i can able to download the other
> machine file, like below path.
> ("AnotherNetworkMachine\temp\ss.pdf")
> But when i place this code my server, the impersonate is doing succuss, but
> its taking too much time to download and finally it says page cannot be
> displayed error.
> any idea.
> bala
> http://west-wind.com/weblog/posts/1572.aspx
> "Brock Allen" wrote:
> > > Thanks for the reply. The user name which i am using is under the same
> > > DOMAIN.
> > Ok, that shouldn't matter with delegation.
> > > Are you mentioning the same domain user or local user for that
> > > machine?
> > For delegation you'll have to be using kerb. The username doesn't matter,
> > the important thing is to configure the server to be trusted for delegation.
> > -Brock
> > DevelopMentor
> > http://staff.develop.com/ballen
On Mon, 29 Aug 2005 13:45:32 -0700, "Bala" <Bala@.discussions.microsoft.com> wrote:

Hi Brock,

If i create a local account on webserver and same username and password for
network machine to local, In this point can i able to download the file?

As Brock was indicating, you need to delegate credentials which requires Kerberos if your web
application is configured for Integrated Windows Security.

How to configure an ASP.NET application for a delegation scenario
http://support.microsoft.com/defaul...kb;en-us;810572

Paul
~~~~
Microsoft MVP (Visual Basic)

Permission denied problem. please help me

Hi All,
I am trying to download the file from network machine (under same domain). I
am using below link page code to impersonate.
http://www.netomatix.com/ImpersonateUser.aspx
I can able to impersonate the user, when i try to download the file, its
says "unknown user name and password". I given full permission to domain
user. but the same time when i provied the user name and deails on webconfig
file like below, its allowing me to download.
<identity impersonate="true" userName="mydomain\bala" password="password" />
I dont know where the problem is. Can anyone please give me idea to resolve
this.
I am trying to fix this problem past 3 days.
below is the complete code i am using...
i am getting error on response.writefile. This is the error message
Logon failure: unknown user name or bad password.
exception Details: System.IO.IOException: Logon failure: unknown user name
or bad password.
code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim impContext As WindowsImpersonationContext = Nothing
Try
impContext = NetworkSecurity.ImpersonateUser("mydomain",
"bala", "password", LogonType.LOGON32_LOGON_NETWORK,
LogonProvider.LOGON32_PROVIDER_DEFAULT)
Catch ex As ApplicationException
impContext.Undo()
Response.Write(ex.Message)
End Try
If Not (Nothing Is impContext) Then
Try
Catch ex As Exception
Response.Write(ex.Message)
Finally
impContext.Undo()
If Page.IsPostBack Then
Dim spath As String
spath = "\\laptop02\temp\test.pdf"
'DownloadFile(spath, True)
Dim path1 As String = spath
Dim name As String = Path.GetFileName(path1)
Dim ext As String = Path.GetExtension(path1)
Dim type As String = ""
If Not (ext Is Nothing) Then
Select Case ext.ToLower
Case ".htm", ".html"
type = "text/HTML"
' break
Case ".txt"
type = "text/plain"
' break
Case ".doc", ".rtf"
type = "Application/msword"
' break
Case ".pdf"
type = "Application/pdf"
End Select
End If
'If forceDownload Then
Response.AppendHeader("content-disposition",
"attachment; filename = " & name)
'End If
If Not (type = "") Then
Response.ContentType = type
End If
Response.WriteFile(path1)
Response.End()
End If
End Try
End If
End Sub
thanks
balaImpersonation only allows access to local resources as the user who's using
your site. You want delegation which will allow off-host access as the user
who has authenticated in the browser. In essence it means you need to enable
this in AD for the machine that's running your webserver. Check out this
for more info:
http://pluralsite.com/wiki/default...elop.com/ballen

> Hi All,
> I am trying to download the file from network machine (under same
> domain). I am using below link page code to impersonate.
> http://www.netomatix.com/ImpersonateUser.aspx
> I can able to impersonate the user, when i try to download the file,
> its says "unknown user name and password". I given full permission to
> domain user. but the same time when i provied the user name and deails
> on webconfig file like below, its allowing me to download.
> <identity impersonate="true" userName="mydomain\bala"
> password="password" />
> I dont know where the problem is. Can anyone please give me idea to
> resolve this. I am trying to fix this problem past 3 days.
> below is the complete code i am using...
> i am getting error on response.writefile. This is the error message
> Logon failure: unknown user name or bad password. exception Details:
> System.IO.IOException: Logon failure: unknown user name or bad
> password.
> code:
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim impContext As WindowsImpersonationContext = Nothing
> Try
> impContext =
> NetworkSecurity.ImpersonateUser("mydomain",
> "bala", "password", LogonType.LOGON32_LOGON_NETWORK,
> LogonProvider.LOGON32_PROVIDER_DEFAULT)
> Catch ex As ApplicationException
> impContext.Undo()
> Response.Write(ex.Message)
> End Try
> If Not (Nothing Is impContext) Then
> Try
> Catch ex As Exception
> Response.Write(ex.Message)
> Finally
> impContext.Undo()
> If Page.IsPostBack Then
> Dim spath As String
> spath = "\\laptop02\temp\test.pdf"
> 'DownloadFile(spath, True)
> Dim path1 As String = spath
> Dim name As String = Path.GetFileName(path1)
> Dim ext As String = Path.GetExtension(path1)
> Dim type As String = ""
> If Not (ext Is Nothing) Then
> Select Case ext.ToLower
> Case ".htm", ".html"
> type = "text/HTML"
> ' break
> Case ".txt"
> type = "text/plain"
> ' break
> Case ".doc", ".rtf"
> type = "Application/msword"
> ' break
> Case ".pdf"
> type = "Application/pdf"
> End Select
> End If
> 'If forceDownload Then
> Response.AppendHeader("content-disposition",
> "attachment; filename = " & name)
> 'End If
> If Not (type = "") Then
> Response.ContentType = type
> End If
> Response.WriteFile(path1)
> Response.End()
> End If
> End Try
> End If
> End Sub
> thanks
> bala
Hi Brock,
Thanks for the reply. The user name which i am using is under the same
DOMAIN.
Are you mentioning the same domain user or local user for that machine?
Thanks
bala
"Brock Allen" wrote:

> Impersonation only allows access to local resources as the user who's usin
g
> your site. You want delegation which will allow off-host access as the use
r
> who has authenticated in the browser. In essence it means you need to enab
le
> this in AD for the machine that's running your webserver. Check out this
> for more info:
> http://pluralsite.com/wiki/default...elop.com/ballen
>
>
>
>
> Thanks for the reply. The user name which i am using is under the same
> DOMAIN.
Ok, that shouldn't matter with delegation.

> Are you mentioning the same domain user or local user for that
> machine?
For delegation you'll have to be using kerb. The username doesn't matter,
the important thing is to configure the server to be trusted for delegation.
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi Brock,
Using this below link code i can able to impersonate the user on my domain
user account. From my locl machine IIS i can able to download the other
machine file, like below path.
("AnotherNetworkMachine\temp\ss.pdf")
But when i place this code my server, the impersonate is doing succuss, but
its taking too much time to download and finally it says page cannot be
displayed error.
any idea.
bala
http://west-wind.com/weblog/posts/1572.aspx
"Brock Allen" wrote:

> Ok, that shouldn't matter with delegation.
>
> For delegation you'll have to be using kerb. The username doesn't matter,
> the important thing is to configure the server to be trusted for delegatio
n.
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
Hi Brock,
If i create a local account on webserver and same username and password for
network machine to local, In this point can i able to download the file?
thanks
bala
"Brock Allen" wrote:

> Ok, that shouldn't matter with delegation.
>
> For delegation you'll have to be using kerb. The username doesn't matter,
> the important thing is to configure the server to be trusted for delegatio
n.
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
sorry. when i run the application on same domain its download the file. but
from outside i am getting error. so that wont work.
bala
"Bala" wrote:
> Hi Brock,
> Using this below link code i can able to impersonate the user on my domain
> user account. From my locl machine IIS i can able to download the other
> machine file, like below path.
> ("AnotherNetworkMachine\temp\ss.pdf")
> But when i place this code my server, the impersonate is doing succuss, bu
t
> its taking too much time to download and finally it says page cannot be
> displayed error.
> any idea.
> bala
> http://west-wind.com/weblog/posts/1572.aspx
> "Brock Allen" wrote:
>
On Mon, 29 Aug 2005 13:45:32 -0700, "Bala" <Bala@.discussions.microsoft.com>
wrote:
Hi Brock,
If i create a local account on webserver and same username and password fo
r
network machine to local, In this point can i able to download the file?
As Brock was indicating, you need to delegate credentials which requires Ker
beros if your web
application is configured for Integrated Windows Security.
How to configure an ASP.NET application for a delegation scenario
http://support.microsoft.com/defaul...kb;en-us;810572
Paul
~~~~
Microsoft MVP (Visual Basic)