accessing Resource in ACTIVEX DLL from aspx page - asp.net

I have an activeX dll that was written in vb6. Inside that code it uses the LoadResPicture() to load an image that it then sends to a printer (using PaintPicture)
If I call this DLL using an ASPX page, that hosted on a Windows 2008 box running IIS 7.0, the image doesn't print.
If I call this DLL using a VBS script on the very same server, the image prints fine.
The image used to print fine when the aspx page was hosted on a Windows 2000 Server.
Here is the VBS Code:
Dim CheckCtl
set CheckCtl = CreateObject("CHECKCONTROL.CHECK")
CheckCtl.FBOAccountID = 2765
CheckCtl.includesignature = True
CheckCtl.Amount = 500.00
CheckCtl.CheckDate = #04/06/2011#
CheckCtl.Payee_L1 = "Donald Trump"
CheckCtl.Payee_L2 = "10 Park Place"
CheckCtl.Payee_L3 = "Atlantic City, NJ 00011"
CheckCtl.Payee_L4 = ""
CheckCtl.Notes = "This is a test check"
CheckCtl.SubmittedBy = "Accountant"
dim lSuccess
lSuccess = CheckCtl.Printcheck()
Here is the ASPX VB.NET Code:
Dim CheckCtl As checkcontrolNET.Check
CheckCtl = New checkcontrolNET.Check
CheckCtl.FBOAccountId = 2765
CheckCtl.IncludeSignature = True
CheckCtl.Amount = 500.0
CheckCtl.CheckDate = "04/06/2011"
CheckCtl.Payee_L1 = "Donald Trump"
CheckCtl.Payee_L2 = "10 Park Place"
CheckCtl.Payee_L3 = "Atlantic City, NJ 00011"
CheckCtl.Payee_L4 = ""
CheckCtl.notes = "This is a test check"
CheckCtl.SubmittedBy = "Accountant"
Dim lSuccess As Boolean
lSuccess = CheckCtl.printcheck()
Response.Write(lSuccess)
What am I missing?

Is your server 64-bit by any chance? According to MSDN, the .Net version of that function is only supported on 32-bit versions so its possible the same may be true for the VB6 version.
http://msdn.microsoft.com/en-us/library/ms652936.aspx

I found COM+ approach for VB ActiveX with IIS wacky. I hope you have control over VB6 Dlls code and if so, try putting this code into the VB6 class you are trying to instantiate.
Private moScriptCtx As ScriptingContext
Public Sub OnStartPage(SC As ScriptingContext)
Set moScriptCtx = SC
End Sub
You can now access Request,Response,Server etc as properties of the moScriptCtx object. ASP automagically calls OnStartPage() for you during the CreateObject execution.
[EDIT]
This may not be useful in your case if you are not useing ASP's intrinsic properties, but try enabling this on COM+ management console.
Fire up the COM+ management consoleo
Find the COM+ Application in questiono
Find the applicable component in the 'Components' folder
Right click on it and choose properties
Select the Advanced tab
Check the 'Allow IIS Intrinsic Properties' checkbox
http://blogs.msdn.com/b/distributedservices/archive/2010/04/28/iis-intrinsic-properties-are-disabled-by-default-on-windows-2008-and-windows-2008-r2.aspx

This sounds suspiciously like a permissions problem. I suspect that your Windows 2000 server ran IIS under the SYSTEM account and probably did the same with the old ASPNET worker process account.
Check that the account that the site runs under has permissions to print. Depending on how you've secured the site this could be any one of:
The application pool identity
A specific anonymous account
The IUSR account

Related

Adding appointment to outlook using asp.net

I am developing a web application in asp.net web forms framework. one of the requirement of application is to save records of future appointments of user. User also want to add this appointment to his outlook calendar. Now the problem is that my code is working locally. Appointments are being saved when I test application on my local machine. But when I deploy application on live server code give error and appointment do not saves in my outlook calendar. Kindly help me how to make it work on live server. Following is the code I'm using
Private Sub AddToCalander()
Try
Dim olApp As Microsoft.Office.Interop.Outlook._Application = DirectCast(New Microsoft.Office.Interop.Outlook.Application(), Microsoft.Office.Interop.Outlook._Application)
Dim mapiNS As Microsoft.Office.Interop.Outlook.NameSpace = olApp.GetNamespace("MAPI")
Dim profile As String = ""
mapiNS.Logon(profile, Nothing, Nothing, Nothing)
Dim apt As Microsoft.Office.Interop.Outlook._AppointmentItem = DirectCast(olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem), Microsoft.Office.Interop.Outlook._AppointmentItem)
apt.Subject = ddItineraryItems.SelectedItem.Text
apt.Body = txtPItinerary_Desc.Text
apt.Start = CDate(txtDateFromPopup.Text)
apt.End = CDate(txtDateToPopup.Text)
apt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olTentative
apt.AllDayEvent = False
apt.Location = dcmbDealer.SelectedItem.Text & "," & dcmbShowroom.SelectedItem.Text
apt.Save()
Catch ex As Exception
AlertMessage.showError("Unable to add itinerary detail to outlook calendar")
Exit Sub
End Try
End Sub
I get the code from here.
http://www.codeproject.com/Tips/384326/Add-to-Calender-Adding-event-to-Microsoft-Outlook
If you are going to use Outlook by Interop, then you would need to install it on your server. Without installed Outlook - it won't work.
PS. Your code will work only with Outlook account that is configured by default. And it will work only if you are using external service for appointments. Otherwise it will save that appointment just to Outlook on server, without updating it to your local Outlook
And using Interop in web applications on server side isn't a good idea, as it will starts new Outlook process every time, that is very resource expensive. Better way is to integrate with Calendar system that you are using, like Google Calendar, etc.

SEND OBJECT isn't available for one User in a Spilt-database

I have one User getting an error message in a MS ACCESS split database. The message is "The command or action "Send Object" isn't available now." The User gets this message when they are clicking on a command button that is suppose to open GroupWise e-mail and copy text from a MSACCESS form and have the TO: FROM: and SUBJECT: lines auto-populate.
I looked at the USER's Internet Explorer settings.
I checked to see if the USER has the most recent MS JET 4.0
I provided another copy of the front-end to save to the desktop
All other Users are not experiencing this problem. I must also add that this specific User was recently upgraded to MS OFFICE 2010, like the rest of us... Any suggestions ? Thanks
For anyone passing by on Google, this worked for me. The affected users had recently upgraded to Windows 7 with 32-bit Office 2010 (although some had upgraded without issue). It also works on my local machine (Windows 7 with 64-bit Office 2010).
Instead of using DoCmd.SendObject(....):
Sub SendMail()
Dim myOb As Object
Dim AutoSend as boolean
Set myOb = CreateObject("Outlook.Application")
Set oMail = myOb.CreateItem(olMailItem)
//Set whether to send email automatically or make user press Send
AutoSend = False
With oMail
.Body = "Message text"
.Subject = "Subject line"
.To = To#example.com
.cc = cc#example.com
If AutoSend Then
.send
Else
.display
End If
End With
Set oMail = Nothing
Set oApp = Nothing
End Sub

LDAP Error in IIS7.5 while using windows Authentication

I'm having facing problemind with LDAP, its bit strange one. My Web server is IIS7.5(windows server 2008 R2). Its configured to use windows Authentication. I've pasted my asp page below.
Web browser is IE8, Have added the website to intranet zone and enabled send, user details if intranet zone in security tab->custom level. Intigrated windows authentication is enabled in advanced tab.
Everything works fine for 20minutes(Session time setiing and other default time out settings are for 20min). After 20minutes I get it ASP runtime error. Which says method or property memberOf for object objUser is not supported. When I get below error I change the Authentication type to basic Authentication. It prompts for windows credentials and works fine. After that I again revert back to windows authentication. And it works for sometime.
Not sure if IIS7.5 id configured with basic authentication enabled and IE8 configured as above, still why it prompts for windows Credential. Though windows Authentication mode doesn't prompt for credential, It works fine but for certain period. Can any one explain me why this strange behaviour and solution to fix this one?
<%# LANGUAGE="VBSCRIPT" %>
<%
Option Explicit
Dim oADSysInfo
Dim objUser
Dim strGroupData
Dim strUserDN
Dim arrGroups
Dim strGroup
Dim wsObject
Dim netSys
Dim strUsrDomain
strGroupData = ""
Set wsObject = CreateObject("WScript.Shell")
Set netSys = CreateObject("WScript.Network")
strUsrDomain = netSys.UserDomain
Set oADSysInfo = CreateObject("ADSystemInfo")
If err.number <> 0 Then
'getLDAPGroupInfo = strGroupData
'wsObject.popup("Error"& e.decription)
'Exit Function
End If
strUserDN = oADSysInfo.UserName
Set objUser = GetObject("LDAP://"& strUserDN)
arrGroups = objUser.memberOf
If IsEmpty(arrGroups) Then
'Wscript.Echo "Member of no groups"
ElseIf (TypeName(arrGroups) = "String") Then
'Wscript.Echo "Member of group " & arrGroups
strGroupData = arrGroups
Else
For Each strGroup In arrGroups
strGroupData = strGroupData & "," & strGroup
Next
'strGroupData = arrGroups
End If
Response.Write(strGroupData)
%>
I employed rather simple solution.
Solution I employed was as follows.
My Application is running under specific user identity(Physical path credential and Application pool idenity set to DNS account)
I created another page with above code and ran under applcation pool identity(SPN) and there by created a primary token key between Active Directory server and Webserver server
Using that key I again connected to LDAP to query user related info by calling above code under virtual directory having windows authentication and and running under user identity, there by getting user details.
If you are using asp.net programmatically impersonate user and get user detail from ldap and on application start create primary token by connecting ldap, The primary key persists till worker process is killed

Adding a work item to TFS 2010 from ASP.NET app fails due to permissions

I'm working on an ASP.NET webforms app that will serve as a simple intake form to create work items in TFS 2010.
The app works correctly when I run it locally in debug mode--the submission completes and the work item is created.
When I publish the form to our dev server, it yellow screens and throws the following error:
[SecurityException: TF50309: The
following account does not have
sufficient permissions to complete the
operation: DOMAINNAME\SERVERNAME$. The
following permissions are needed to
perform this operation: View
collection-level information.]
In my code, I'm attempting to access TFS using a service account, and from what I can tell the service account is being used correctly when I run in debug mode.
Here's what my C# looks like:
string tfsServerUrl = "http://servername:8080/tfs";
string tfsProject = "Web Team Projects";
NetworkCredential tfsCredential = new NetworkCredential("ServiceAccountName", "password", "DOMAIN");
TeamFoundationServer tfs = new TeamFoundationServer(tfsServerUrl, tfsCredential);
tfs.Authenticate();
WorkItemStore workItemStore = new WorkItemStore(tfsServerUrl);
If I set a breakpoint at the tfs.Authenticate() line, the server object shows the service account name as the current user and IsAuthenticated = true.
The line in the exception that mentions SERVERNAME$ is what's stumping me. It's seems like IIS is deciding to try to access TFS with the app pool identity instead of the credentials that I'm explicitly supplying.
Our dev server is a Server 2008 box running IIS 7.
Any suggestions?
The TeamFoundationServer class is obselete. Have you tried using the TfsTeamProjectCollection (TFS 2008) or TfsConfigurationServer (2010) class instead?
string tfsServerUrl = "http://servername:8080/tfs";
System.Net.NetworkCredential tfsCredential = new System.Net.NetworkCredential("ServiceAccountName", "password", "DOMAIN");
TfsConfigurationServer tfs = new TfsConfigurationServer(new Uri(tfsServerUrl), tfsCredential);
tfs.Authenticate(); // You should be able to omit this
WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

Getting 2032 error (On only 1 machine)

I built an AIR app a while ago. One of the users today got a new machine (XP) and keeps getting a 2032 error when the app tries to send/receive data via HTTPService I verified that this page works when accessed within a web browser. It also works on AIR apps on other machines. The page and the AIR app haven't been changed for months, the only thing that has changed is this particular users computer. I recompiled to get a more specific error and this is what I got:
(mx.messaging.messages::ErrorMessage)#0
body = ""
clientId = "DirectHTTPChannel0"
correlationId = "B38588EC-AEA0-84F0-F5B2-F6B6AB6C3456"
destination = ""
extendedData = (null)
faultCode = "Server.Error.Request"
faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032" errorID=2032]. URL: https://www.example.com/mypage.php"
faultString = "HTTP request error"
headers = (Object)#1
DSStatusCode = 0
messageId = "2BC38D14-63DD-345E-50DD-F6B6AEE75438"
rootCause = (flash.events::IOErrorEvent)#2
bubbles = false
cancelable = false
currentTarget = (flash.net::URLLoader)#3
bytesLoaded = 0
bytesTotal = 0
data = ""
dataFormat = "text"
errorID = 2032
eventPhase = 2
target = (flash.net::URLLoader)#3
text = "Error #2032"
type = "ioError"
timestamp = 0
timeToLive = 0
As I am writing this I had the user restart and relaunch the application, it is now working so I am not too worried about it, but I am still curious what could have happened if anyone has any ideas?
Update
Today (next day) It is happening again and restart isn't even fixing it today. It has to be something on her machine interfering causing the problem because I can run the program on any other machine just fine with no problem. Not sure what it could be or how to troubleshoot that?
Did the server hiccup just then, i.e. downtime and/or cosmic ray? Cross reference the user access time with the apache access/error.log on the server. Did crossdomain.xml change anyplace that your program references?
I had somewhat the same problem here but with a Flash (Web - Flex 4.1 SDK) application.
after trying out a huge assortment of solutions we narrowed we finally came up with one that works pretty reliably for all systems, including newly installed machines.
A. add global event listeners at the root (or stage) of the application, on flex preinitialize stage.
IOErrorEvent.IO_ERROR
IOErrorEvent.NETWORK_ERROR
HTTPStatusEvent.HTTP_STATUS
ErrorEvent.ERROR
SecurityErrorEvent.SECURITY_ERROR
if an error is cought - event.preventDefault();
B. add event listeners on every loader used in the App for the following errors:
IOErrorEvent.IO_ERROR
SecurityErrorEvent.SECURITY_ERROR
HTTPStatusEvent.HTTP_STATUS
*to attempt recovery, like falling back to an external interface call...
C. place all the SWZ files from the bin-release folder together with the SWF file in the same path on the server you use to deliver your App.
in my case these are the files needed:
sparkskins_4.5.1.21328.swz
spark_4.5.1.21328.swz
textLayout_2.0.0.232.swz
rpc_4.5.1.21328.swz
osmf_1.0.0.16316.swz
framework_4.5.1.21328.swz
* to discover this i used Chrome developer console to see which errors occur on the page and discovered a chain of 404s when the app tries to download these files.
D. have a properly configured crossdomain.xml policy file which includes the allow http request xml tag.
<allow-http-request-headers-from domain="*" headers="*"/>
replace the * as needed in your particular case.
Cheers

Resources