OWC COM Object Credentials in ASP.NET and Web Services

T

Trevor Howe

Hi All

I got hold of an article about building an OLAP Reporting APP in ASP.Net.
This article makes use of a Pivot Table on a web form and then uses a web
service to set the various properties on the Pivot table. Here is a link to
that article:

http://msdn.microsoft.com/msdnmag/issues/03/10/OLAP/default.aspx

I found that the code worked fine except when I was trying to communicate
with the fieldset property of the Pivot view. It gave an interop.owc10
unspecified error (which tells me nothing). After two weeks of
troubleshooting, and the help of one of my colleagues who knows a lot more
about .Net than me, we have narrowed this problem down to a permissions issue
on the COM component (i.e. the Pivot table object on the web form).

We have enabled impersonation by setting the <identity impersonate="true" />
in the web.config file. This allows the signed on users credentials to go
through instead of the ASPNET account. The problem was that these same
credentials were not being passed to the COM object. The solution, we found,
was to set the ASPCOMPAT property of the web form page to true. This works if
the code is sitting in code behind form, BUT NOT FOR WEB SERVICES.

I need to get this up and running using web services, but web services does
not have any ASPCOMPAT property.

What now? Is there any better way to do this? I am pretty new to .net, so
any help would be appreciated.

PS. Alvin this is a continuation of my previous post from TJCube. I am sure
that in your research for your .Net book, you might have come across this
problem before.

PPS. Jeffrey Hasan, Kenneth Tu - as authors of the article and accompanying
source code, can't you can shed some light on this matter?
 
A

Alvin Bruney [ASP.NET MVP]

I actually thought about this for the entire day because it disturbed me
that Aspcompat would fix the issue. I have a clue but I'm not entirely
convinced that this is the sole reason.
PS. Alvin this is a continuation of my previous post from TJCube. I am sure
that in your research for your .Net book, you might have come across this
problem before.
That's a wise move to make that connection (i can hear the desperation in
your voice). I did fix this issue once. I'm straining to remember what i did
(old age).

So, one thing that you can do - since i suspect this issue is because of the
request being serviced on an MTA thread pool that lacks the appropriate
permission, you will need to make sure that the account is part of the OLAP
administration account. If that doesn't fix it, here is your next step.

instead of guessing, ask the webservice to tell you what account it is being
run under. For instance, do this
[webmethod]
public string whoami()
{
//it would help to verify this line cuz it came from a tired brain
return System.Windows.Security.Principal.WindowsIdentity.Name;
}

so let's say it returns NETWORK SERVICE/vapor, you would turn around and add
the appropriate olap permissions to the vapor account. That should fix it
for you.

The reason it works in the code-behind is because impersonation forces the
executing thread to have the correct permissions, however, a web request
from a webservice would use the default account.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
 
T

Trevor Howe

Hi Alvin

First a simple equation:
TJCube = Trevor Howe

I am one and the same person, decided to drop the pseudonym and get personal.

Ok, I tried your suggestion below. The line in your code below does not work:
return System.Windows.Security.Principal.WindowsIdentity.Name.

but this line works:
return System.Security.Principal.WindowsIdentity.GetCurrent().Name;

When I ran this I got my user name being returned because I have set
impersonate = true in my web.config. I am registered in the OLAP
Administrators group on the Analysis server. Taking impersonate = true out of
the equation, I get <machine name>/ASPNET as the user and that user is not in
the OLAP Administrators group. I aam having difficulties adding this machine
name and user to the OLAP Administrators group on the production server.

I created a "bare bones" test that consists of a web form with just enough
code to instantiate a pivot table class object and then down to talking to a
fieldset related property. This form had aspcompat = true and no web service
stuff at all. This code worked.

I also read somewhere that aspcompat cannot be used for web services and
there is no equivalent. In your experience (ok I wont mention the book
again), is the web service way the right way to go for OWC pivot table
customisation in .NET. If not, can you point me to some examples/sites (or
books - oops there I go again) where a non web service way of doing server
side calls to a client side OWC component are documented.

As always, your help will be much appreciated.



Alvin Bruney said:
I actually thought about this for the entire day because it disturbed me
that Aspcompat would fix the issue. I have a clue but I'm not entirely
convinced that this is the sole reason.
PS. Alvin this is a continuation of my previous post from TJCube. I am sure
that in your research for your .Net book, you might have come across this
problem before.
That's a wise move to make that connection (i can hear the desperation in
your voice). I did fix this issue once. I'm straining to remember what i did
(old age).

So, one thing that you can do - since i suspect this issue is because of the
request being serviced on an MTA thread pool that lacks the appropriate
permission, you will need to make sure that the account is part of the OLAP
administration account. If that doesn't fix it, here is your next step.

instead of guessing, ask the webservice to tell you what account it is being
run under. For instance, do this
[webmethod]
public string whoami()
{
//it would help to verify this line cuz it came from a tired brain
return System.Windows.Security.Principal.WindowsIdentity.Name;
}

so let's say it returns NETWORK SERVICE/vapor, you would turn around and add
the appropriate olap permissions to the vapor account. That should fix it
for you.

The reason it works in the code-behind is because impersonation forces the
executing thread to have the correct permissions, however, a web request
from a webservice would use the default account.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Trevor Howe said:
Hi All

I got hold of an article about building an OLAP Reporting APP in ASP.Net.
This article makes use of a Pivot Table on a web form and then uses a web
service to set the various properties on the Pivot table. Here is a link
to
that article:

http://msdn.microsoft.com/msdnmag/issues/03/10/OLAP/default.aspx

I found that the code worked fine except when I was trying to communicate
with the fieldset property of the Pivot view. It gave an interop.owc10
unspecified error (which tells me nothing). After two weeks of
troubleshooting, and the help of one of my colleagues who knows a lot more
about .Net than me, we have narrowed this problem down to a permissions
issue
on the COM component (i.e. the Pivot table object on the web form).

We have enabled impersonation by setting the <identity impersonate="true"
/>
in the web.config file. This allows the signed on users credentials to go
through instead of the ASPNET account. The problem was that these same
credentials were not being passed to the COM object. The solution, we
found,
was to set the ASPCOMPAT property of the web form page to true. This works
if
the code is sitting in code behind form, BUT NOT FOR WEB SERVICES.

I need to get this up and running using web services, but web services
does
not have any ASPCOMPAT property.

What now? Is there any better way to do this? I am pretty new to .net, so
any help would be appreciated.

PS. Alvin this is a continuation of my previous post from TJCube. I am
sure
that in your research for your .Net book, you might have come across this
problem before.

PPS. Jeffrey Hasan, Kenneth Tu - as authors of the article and
accompanying
source code, can't you can shed some light on this matter?
 
A

Alvin Bruney [ASP.NET MVP]

I also read somewhere that aspcompat cannot be used for web services and
there is no equivalent.
Right, because Aspcompat is a page level property.

There is another way. You can use the XML-HTTP method.
http://aspfaqs.com/aspfaqs/showfaq.asp?FAQID=61 to get you started.
After you understand the code snippet, you can modify appropriately to send
and receive data from the server
or cube. Here is an excerpt from the black book p. 306. So the approach
would be to keep your server-side code that works and use XMLHTTP to connect
your client to your already working server-side code.


XMLHTTP submission




The two previous methods both force a server post. This approach retrieves
data from the server using an XMLHTTP connection that is not as expensive as
submitting an entire form to the server because the DOM object is not forced
to reload to refresh the page. It uses an ActiveX control available with
Microsoft Internet Explorer 5+. The ActiveX control takes care of submitting
the data and retrieving the contents from the server without suffering the
painful postback flash inherent in ASP.NET web applications. Let us examine
the code.




Code-listing 8.9 XML-HTTP submission




Javascript




<script>

function __ExecutePost(command){

var obj = new ActiveXObject("Microsoft.XMLHTTP");

if(obj != null){

obj.Open('GET','webform1.aspx'+'?__COMMAND='+command,false);

obj.Send();

var s = obj.responseText;

alert(s)

}

else

alert('Unable to create client object');

}

</script>




VBScript




<script>

function __ExecutePost(command){

var obj = new ActiveXObject("Microsoft.XMLHTTP");

if(obj != null){

obj.Open('GET','webform1.aspx'+'?__COMMAND='+command,false);

obj.Send();

var s = obj.responseText;

alert(s)

}

else

alert('Unable to create client object');

}

</script>







Notice that our javascript function takes a command parameter. Next, the
XMLHTTP object is instantiated on the client. The contents of the parameter
are assigned to a variable called _COMMAND. Finally, the third parameter
indicates that we are only interested in synchronous processing of the
function. A value of true for this parameter would initiate asynchronous
processing. Here is what the code-behind looks like for this approach.




Code-listing 8.10 XML-HTTP submission codebehind




C# Snippet




private void Page_Load(object sender, System.EventArgs e)

{

AddButton.Attributes.Add("onclick","__ExecutePost('EDIT'); return false;");




switch(Request["__COMMAND"])

{

case "EDIT":

Response.Write("success");

Response.End();

break;

default:

break;

}

}




VBScript




Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

AddButton.Attributes.Add("onclick","__ExecutePost('EDIT'); return false;")




Select Case Request("__COMMAND")

Case "EDIT"

Response.Write("success")

Response.End()

Exit Sub

Case Else

Exit Sub

End Select

End Sub







The code assumes that a server-side button with id equal to AddButton is
placed on a form. Its onclick event is mapped to the javascript function
__ExecutePost and a parameter is passed in. Finally, the normal server-side
event is canceled by setting the return to false to cancel the post.

Inside the switch event, some action is taken and Response.End() is called
to terminate processing on the server. This Response.End() call is necessary
to prevent the entire page response from being returned to the client.

Response.End() causes a thread abort exception to be thrown which may incur
a performance penalty cost and is not elegant. To avoid this, you may
consider using HttpContext.Current.ApplicationInstance.CompleteRequest
instead because it does not induce a thread abort exception.


--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Trevor Howe said:
Hi Alvin

First a simple equation:
TJCube = Trevor Howe

I am one and the same person, decided to drop the pseudonym and get
personal.

Ok, I tried your suggestion below. The line in your code below does not
work:
return System.Windows.Security.Principal.WindowsIdentity.Name.

but this line works:
return System.Security.Principal.WindowsIdentity.GetCurrent().Name;

When I ran this I got my user name being returned because I have set
impersonate = true in my web.config. I am registered in the OLAP
Administrators group on the Analysis server. Taking impersonate = true out
of
the equation, I get <machine name>/ASPNET as the user and that user is not
in
the OLAP Administrators group. I aam having difficulties adding this
machine
name and user to the OLAP Administrators group on the production server.

I created a "bare bones" test that consists of a web form with just enough
code to instantiate a pivot table class object and then down to talking to
a
fieldset related property. This form had aspcompat = true and no web
service
stuff at all. This code worked.

I also read somewhere that aspcompat cannot be used for web services and
there is no equivalent. In your experience (ok I wont mention the book
again), is the web service way the right way to go for OWC pivot table
customisation in .NET. If not, can you point me to some examples/sites (or
books - oops there I go again) where a non web service way of doing server
side calls to a client side OWC component are documented.

As always, your help will be much appreciated.



Alvin Bruney said:
I actually thought about this for the entire day because it disturbed me
that Aspcompat would fix the issue. I have a clue but I'm not entirely
convinced that this is the sole reason.
PS. Alvin this is a continuation of my previous post from TJCube. I am
sure
that in your research for your .Net book, you might have come across
this
problem before.
That's a wise move to make that connection (i can hear the desperation in
your voice). I did fix this issue once. I'm straining to remember what i
did
(old age).

So, one thing that you can do - since i suspect this issue is because of
the
request being serviced on an MTA thread pool that lacks the appropriate
permission, you will need to make sure that the account is part of the
OLAP
administration account. If that doesn't fix it, here is your next step.

instead of guessing, ask the webservice to tell you what account it is
being
run under. For instance, do this
[webmethod]
public string whoami()
{
//it would help to verify this line cuz it came from a tired brain
return System.Windows.Security.Principal.WindowsIdentity.Name;
}

so let's say it returns NETWORK SERVICE/vapor, you would turn around and
add
the appropriate olap permissions to the vapor account. That should fix it
for you.

The reason it works in the code-behind is because impersonation forces
the
executing thread to have the correct permissions, however, a web request
from a webservice would use the default account.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Trevor Howe said:
Hi All

I got hold of an article about building an OLAP Reporting APP in
ASP.Net.
This article makes use of a Pivot Table on a web form and then uses a
web
service to set the various properties on the Pivot table. Here is a
link
to
that article:

http://msdn.microsoft.com/msdnmag/issues/03/10/OLAP/default.aspx

I found that the code worked fine except when I was trying to
communicate
with the fieldset property of the Pivot view. It gave an interop.owc10
unspecified error (which tells me nothing). After two weeks of
troubleshooting, and the help of one of my colleagues who knows a lot
more
about .Net than me, we have narrowed this problem down to a permissions
issue
on the COM component (i.e. the Pivot table object on the web form).

We have enabled impersonation by setting the <identity
impersonate="true"
/>
in the web.config file. This allows the signed on users credentials to
go
through instead of the ASPNET account. The problem was that these same
credentials were not being passed to the COM object. The solution, we
found,
was to set the ASPCOMPAT property of the web form page to true. This
works
if
the code is sitting in code behind form, BUT NOT FOR WEB SERVICES.

I need to get this up and running using web services, but web services
does
not have any ASPCOMPAT property.

What now? Is there any better way to do this? I am pretty new to .net,
so
any help would be appreciated.

PS. Alvin this is a continuation of my previous post from TJCube. I am
sure
that in your research for your .Net book, you might have come across
this
problem before.

PPS. Jeffrey Hasan, Kenneth Tu - as authors of the article and
accompanying
source code, can't you can shed some light on this matter?
 
T

Trevor Howe

Thanks Alvin, I will have a look at this approach tomorrow.

Also my resident .Net boffin pointed me to this article that talks about
getting a COM component to work via a web service:

http://www.builderau.com.au/architect/webservices/0,39024590,20283057,00.htm

Maybe you can have a look and see if this might solve the problem.

Finally, when is your book going to hit amazon.com. Trying to motivate the
company to purchase your book and I dont think they are quite comfortable
with lulu.com. We are in South Africa and postal rates could be quite steep.
Our local online book site is http://www.kalahari.net. Would'nt it be great
if your book was made available there - hint, hint.

Just surfing for this problem, it seems there is a demand for updated help
on Office Web Components in .Net.

Thanks
Trevor

Alvin Bruney said:
I also read somewhere that aspcompat cannot be used for web services and
there is no equivalent.
Right, because Aspcompat is a page level property.

There is another way. You can use the XML-HTTP method.
http://aspfaqs.com/aspfaqs/showfaq.asp?FAQID=61 to get you started.
After you understand the code snippet, you can modify appropriately to send
and receive data from the server
or cube. Here is an excerpt from the black book p. 306. So the approach
would be to keep your server-side code that works and use XMLHTTP to connect
your client to your already working server-side code.


XMLHTTP submission




The two previous methods both force a server post. This approach retrieves
data from the server using an XMLHTTP connection that is not as expensive as
submitting an entire form to the server because the DOM object is not forced
to reload to refresh the page. It uses an ActiveX control available with
Microsoft Internet Explorer 5+. The ActiveX control takes care of submitting
the data and retrieving the contents from the server without suffering the
painful postback flash inherent in ASP.NET web applications. Let us examine
the code.




Code-listing 8.9 XML-HTTP submission




Javascript




<script>

function __ExecutePost(command){

var obj = new ActiveXObject("Microsoft.XMLHTTP");

if(obj != null){

obj.Open('GET','webform1.aspx'+'?__COMMAND='+command,false);

obj.Send();

var s = obj.responseText;

alert(s)

}

else

alert('Unable to create client object');

}

</script>




VBScript




<script>

function __ExecutePost(command){

var obj = new ActiveXObject("Microsoft.XMLHTTP");

if(obj != null){

obj.Open('GET','webform1.aspx'+'?__COMMAND='+command,false);

obj.Send();

var s = obj.responseText;

alert(s)

}

else

alert('Unable to create client object');

}

</script>







Notice that our javascript function takes a command parameter. Next, the
XMLHTTP object is instantiated on the client. The contents of the parameter
are assigned to a variable called _COMMAND. Finally, the third parameter
indicates that we are only interested in synchronous processing of the
function. A value of true for this parameter would initiate asynchronous
processing. Here is what the code-behind looks like for this approach.




Code-listing 8.10 XML-HTTP submission codebehind




C# Snippet




private void Page_Load(object sender, System.EventArgs e)

{

AddButton.Attributes.Add("onclick","__ExecutePost('EDIT'); return false;");




switch(Request["__COMMAND"])

{

case "EDIT":

Response.Write("success");

Response.End();

break;

default:

break;

}

}




VBScript




Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

AddButton.Attributes.Add("onclick","__ExecutePost('EDIT'); return false;")




Select Case Request("__COMMAND")

Case "EDIT"

Response.Write("success")

Response.End()

Exit Sub

Case Else

Exit Sub

End Select

End Sub







The code assumes that a server-side button with id equal to AddButton is
placed on a form. Its onclick event is mapped to the javascript function
__ExecutePost and a parameter is passed in. Finally, the normal server-side
event is canceled by setting the return to false to cancel the post.

Inside the switch event, some action is taken and Response.End() is called
to terminate processing on the server. This Response.End() call is necessary
to prevent the entire page response from being returned to the client.

Response.End() causes a thread abort exception to be thrown which may incur
a performance penalty cost and is not elegant. To avoid this, you may
consider using HttpContext.Current.ApplicationInstance.CompleteRequest
instead because it does not induce a thread abort exception.


--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Trevor Howe said:
Hi Alvin

First a simple equation:
TJCube = Trevor Howe

I am one and the same person, decided to drop the pseudonym and get
personal.

Ok, I tried your suggestion below. The line in your code below does not
work:
return System.Windows.Security.Principal.WindowsIdentity.Name.

but this line works:
return System.Security.Principal.WindowsIdentity.GetCurrent().Name;

When I ran this I got my user name being returned because I have set
impersonate = true in my web.config. I am registered in the OLAP
Administrators group on the Analysis server. Taking impersonate = true out
of
the equation, I get <machine name>/ASPNET as the user and that user is not
in
the OLAP Administrators group. I aam having difficulties adding this
machine
name and user to the OLAP Administrators group on the production server.

I created a "bare bones" test that consists of a web form with just enough
code to instantiate a pivot table class object and then down to talking to
a
fieldset related property. This form had aspcompat = true and no web
service
stuff at all. This code worked.

I also read somewhere that aspcompat cannot be used for web services and
there is no equivalent. In your experience (ok I wont mention the book
again), is the web service way the right way to go for OWC pivot table
customisation in .NET. If not, can you point me to some examples/sites (or
books - oops there I go again) where a non web service way of doing server
side calls to a client side OWC component are documented.

As always, your help will be much appreciated.



Alvin Bruney said:
I actually thought about this for the entire day because it disturbed me
that Aspcompat would fix the issue. I have a clue but I'm not entirely
convinced that this is the sole reason.

PS. Alvin this is a continuation of my previous post from TJCube. I am
sure
that in your research for your .Net book, you might have come across
this
problem before.
That's a wise move to make that connection (i can hear the desperation in
your voice). I did fix this issue once. I'm straining to remember what i
did
(old age).

So, one thing that you can do - since i suspect this issue is because of
the
request being serviced on an MTA thread pool that lacks the appropriate
permission, you will need to make sure that the account is part of the
OLAP
administration account. If that doesn't fix it, here is your next step.

instead of guessing, ask the webservice to tell you what account it is
being
run under. For instance, do this
[webmethod]
public string whoami()
{
//it would help to verify this line cuz it came from a tired brain
return System.Windows.Security.Principal.WindowsIdentity.Name;
}

so let's say it returns NETWORK SERVICE/vapor, you would turn around and
add
the appropriate olap permissions to the vapor account. That should fix it
for you.

The reason it works in the code-behind is because impersonation forces
the
executing thread to have the correct permissions, however, a web request
from a webservice would use the default account.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Hi All

I got hold of an article about building an OLAP Reporting APP in
ASP.Net.
This article makes use of a Pivot Table on a web form and then uses a
web
service to set the various properties on the Pivot table. Here is a
link
to
that article:

http://msdn.microsoft.com/msdnmag/issues/03/10/OLAP/default.aspx

I found that the code worked fine except when I was trying to
communicate
with the fieldset property of the Pivot view. It gave an interop.owc10
unspecified error (which tells me nothing). After two weeks of
troubleshooting, and the help of one of my colleagues who knows a lot
more
about .Net than me, we have narrowed this problem down to a permissions
issue
on the COM component (i.e. the Pivot table object on the web form).

We have enabled impersonation by setting the <identity
impersonate="true"
/>
in the web.config file. This allows the signed on users credentials to
go
through instead of the ASPNET account. The problem was that these same
credentials were not being passed to the COM object. The solution, we
found,
was to set the ASPCOMPAT property of the web form page to true. This
works
if
the code is sitting in code behind form, BUT NOT FOR WEB SERVICES.

I need to get this up and running using web services, but web services
does
not have any ASPCOMPAT property.

What now? Is there any better way to do this? I am pretty new to .net,
so
any help would be appreciated.

PS. Alvin this is a continuation of my previous post from TJCube. I am
sure
that in your research for your .Net book, you might have come across
this
problem before.

PPS. Jeffrey Hasan, Kenneth Tu - as authors of the article and
accompanying
source code, can't you can shed some light on this matter?
 
A

Alvin Bruney [ASP.NET MVP]

http://www.builderau.com.au/architect/webservices/0,39024590,20283057,00.htm
Yes, this method can work as well.
Finally, when is your book going to hit amazon.com.
This is taking more time than I thought. Maybe another 6 - 8 weeks.
As soon as the ISBN issue is resolved, you will be able to order a copy thru
your local bookstore or Amazon etc.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Trevor Howe said:
Thanks Alvin, I will have a look at this approach tomorrow.

Also my resident .Net boffin pointed me to this article that talks about
getting a COM component to work via a web service:

http://www.builderau.com.au/architect/webservices/0,39024590,20283057,00.htm

Maybe you can have a look and see if this might solve the problem.

Finally, when is your book going to hit amazon.com. Trying to motivate
the
company to purchase your book and I dont think they are quite comfortable
with lulu.com. We are in South Africa and postal rates could be quite
steep.
Our local online book site is http://www.kalahari.net. Would'nt it be
great
if your book was made available there - hint, hint.

Just surfing for this problem, it seems there is a demand for updated help
on Office Web Components in .Net.

Thanks
Trevor

Alvin Bruney said:
I also read somewhere that aspcompat cannot be used for web services
and
there is no equivalent.
Right, because Aspcompat is a page level property.

There is another way. You can use the XML-HTTP method.
http://aspfaqs.com/aspfaqs/showfaq.asp?FAQID=61 to get you started.
After you understand the code snippet, you can modify appropriately to
send
and receive data from the server
or cube. Here is an excerpt from the black book p. 306. So the approach
would be to keep your server-side code that works and use XMLHTTP to
connect
your client to your already working server-side code.


XMLHTTP submission




The two previous methods both force a server post. This approach
retrieves
data from the server using an XMLHTTP connection that is not as expensive
as
submitting an entire form to the server because the DOM object is not
forced
to reload to refresh the page. It uses an ActiveX control available with
Microsoft Internet Explorer 5+. The ActiveX control takes care of
submitting
the data and retrieving the contents from the server without suffering
the
painful postback flash inherent in ASP.NET web applications. Let us
examine
the code.




Code-listing 8.9 XML-HTTP submission




Javascript




<script>

function __ExecutePost(command){

var obj = new ActiveXObject("Microsoft.XMLHTTP");

if(obj != null){

obj.Open('GET','webform1.aspx'+'?__COMMAND='+command,false);

obj.Send();

var s = obj.responseText;

alert(s)

}

else

alert('Unable to create client object');

}

</script>




VBScript




<script>

function __ExecutePost(command){

var obj = new ActiveXObject("Microsoft.XMLHTTP");

if(obj != null){

obj.Open('GET','webform1.aspx'+'?__COMMAND='+command,false);

obj.Send();

var s = obj.responseText;

alert(s)

}

else

alert('Unable to create client object');

}

</script>







Notice that our javascript function takes a command parameter. Next, the
XMLHTTP object is instantiated on the client. The contents of the
parameter
are assigned to a variable called _COMMAND. Finally, the third parameter
indicates that we are only interested in synchronous processing of the
function. A value of true for this parameter would initiate asynchronous
processing. Here is what the code-behind looks like for this approach.




Code-listing 8.10 XML-HTTP submission codebehind




C# Snippet




private void Page_Load(object sender, System.EventArgs e)

{

AddButton.Attributes.Add("onclick","__ExecutePost('EDIT'); return
false;");




switch(Request["__COMMAND"])

{

case "EDIT":

Response.Write("success");

Response.End();

break;

default:

break;

}

}




VBScript




Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

AddButton.Attributes.Add("onclick","__ExecutePost('EDIT'); return
false;")




Select Case Request("__COMMAND")

Case "EDIT"

Response.Write("success")

Response.End()

Exit Sub

Case Else

Exit Sub

End Select

End Sub







The code assumes that a server-side button with id equal to AddButton is
placed on a form. Its onclick event is mapped to the javascript function
__ExecutePost and a parameter is passed in. Finally, the normal
server-side
event is canceled by setting the return to false to cancel the post.

Inside the switch event, some action is taken and Response.End() is
called
to terminate processing on the server. This Response.End() call is
necessary
to prevent the entire page response from being returned to the client.

Response.End() causes a thread abort exception to be thrown which may
incur
a performance penalty cost and is not elegant. To avoid this, you may
consider using HttpContext.Current.ApplicationInstance.CompleteRequest
instead because it does not induce a thread abort exception.


--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Trevor Howe said:
Hi Alvin

First a simple equation:
TJCube = Trevor Howe

I am one and the same person, decided to drop the pseudonym and get
personal.

Ok, I tried your suggestion below. The line in your code below does not
work:
return System.Windows.Security.Principal.WindowsIdentity.Name.

but this line works:
return System.Security.Principal.WindowsIdentity.GetCurrent().Name;

When I ran this I got my user name being returned because I have set
impersonate = true in my web.config. I am registered in the OLAP
Administrators group on the Analysis server. Taking impersonate = true
out
of
the equation, I get <machine name>/ASPNET as the user and that user is
not
in
the OLAP Administrators group. I aam having difficulties adding this
machine
name and user to the OLAP Administrators group on the production
server.

I created a "bare bones" test that consists of a web form with just
enough
code to instantiate a pivot table class object and then down to talking
to
a
fieldset related property. This form had aspcompat = true and no web
service
stuff at all. This code worked.

I also read somewhere that aspcompat cannot be used for web services
and
there is no equivalent. In your experience (ok I wont mention the book
again), is the web service way the right way to go for OWC pivot table
customisation in .NET. If not, can you point me to some examples/sites
(or
books - oops there I go again) where a non web service way of doing
server
side calls to a client side OWC component are documented.

As always, your help will be much appreciated.



:

I actually thought about this for the entire day because it disturbed
me
that Aspcompat would fix the issue. I have a clue but I'm not entirely
convinced that this is the sole reason.

PS. Alvin this is a continuation of my previous post from TJCube. I
am
sure
that in your research for your .Net book, you might have come across
this
problem before.
That's a wise move to make that connection (i can hear the desperation
in
your voice). I did fix this issue once. I'm straining to remember what
i
did
(old age).

So, one thing that you can do - since i suspect this issue is because
of
the
request being serviced on an MTA thread pool that lacks the
appropriate
permission, you will need to make sure that the account is part of the
OLAP
administration account. If that doesn't fix it, here is your next
step.

instead of guessing, ask the webservice to tell you what account it is
being
run under. For instance, do this
[webmethod]
public string whoami()
{
//it would help to verify this line cuz it came from a tired brain
return System.Windows.Security.Principal.WindowsIdentity.Name;
}

so let's say it returns NETWORK SERVICE/vapor, you would turn around
and
add
the appropriate olap permissions to the vapor account. That should fix
it
for you.

The reason it works in the code-behind is because impersonation forces
the
executing thread to have the correct permissions, however, a web
request
from a webservice would use the default account.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


Hi All

I got hold of an article about building an OLAP Reporting APP in
ASP.Net.
This article makes use of a Pivot Table on a web form and then uses
a
web
service to set the various properties on the Pivot table. Here is a
link
to
that article:

http://msdn.microsoft.com/msdnmag/issues/03/10/OLAP/default.aspx

I found that the code worked fine except when I was trying to
communicate
with the fieldset property of the Pivot view. It gave an
interop.owc10
unspecified error (which tells me nothing). After two weeks of
troubleshooting, and the help of one of my colleagues who knows a
lot
more
about .Net than me, we have narrowed this problem down to a
permissions
issue
on the COM component (i.e. the Pivot table object on the web form).

We have enabled impersonation by setting the <identity
impersonate="true"
/>
in the web.config file. This allows the signed on users credentials
to
go
through instead of the ASPNET account. The problem was that these
same
credentials were not being passed to the COM object. The solution,
we
found,
was to set the ASPCOMPAT property of the web form page to true. This
works
if
the code is sitting in code behind form, BUT NOT FOR WEB SERVICES.

I need to get this up and running using web services, but web
services
does
not have any ASPCOMPAT property.

What now? Is there any better way to do this? I am pretty new to
.net,
so
any help would be appreciated.

PS. Alvin this is a continuation of my previous post from TJCube. I
am
sure
that in your research for your .Net book, you might have come across
this
problem before.

PPS. Jeffrey Hasan, Kenneth Tu - as authors of the article and
accompanying
source code, can't you can shed some light on this matter?
 
R

ridhi

Hi Friends,

I m facing the same poriblem. i have added identity impersonate="true" in my
web config file.its working fine on my development server but not working on
production server. i m getting the message

<err> Interop.OWC10 - Error HRESULT E_FAIL has been returned from a call to
a Com component. </err>.


Please share solution of this problem with me.

Thanks,
Ridhi Singla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top