LDAP Error in IIS7.5 while using windows Authentication - asp-classic

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

Related

Open Web Page from VB Script using Windows Auth

I have an ASP app. setup using Windows Authentication that I can open from IE without being prompted for credentials, but when I try to open the same ASP app. from a VB Script I get a 401 - not authorized error.
How do I get the VB Script to open the app without supplying credentials?
VB Script:
Dim srvHTTP
set srvHTTP = CreateObject("MSXML2.ServerXMLHttp.3.0")
srvHTTP.open "GET", "http://myserver/sample.aspx", false
srvHTTP.send
WScript.Echo("Status: " & srvHTTP.status)
Try using the WinHttpRequest object instead. It allows you to specify the logon policy. The following example may work for you.
Const AutoLogonPolicy_Always = 0
Dim objWinHttp
Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
objWinHttp.SetAutoLogonPolicy AutoLogonPolicy_Always
objWinHttp.Open "GET", "http://myserver/sample.aspx", False
objWinHttp.Send
You may also need to configure your proxy to enable "keep alive" connections, since NTLM authentication requires a number of handshakes.

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

IIS 7 + Windows Server 2008 - Sending Emails from Classic ASP using CDO

On our existing platform we decided to upgrade our development server from Windows Server 2003 to 2008 some time ago.
The problem we are facing is that all asp scripts that used to send emails before when we had Windows Server 2003 worked. Now, they stopped working with no error on page or on the SMTP logs.
If I use telnet to send an email manually works fine.
But it's not working from our classic asp scripts.
This is our ASP code
Sub SendEmail(fromEmail, toEmail, ccEmail, bccEmail, subject, body, somefiles)
Set m_Mailer = Server.CreateObject("CDO.Message")
With m_Mailer.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smptserver") = Request.ServerVariables("server_name")
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory")=SMTP_SERVER_PICKUP_DIRECTORY
.Update
End With
If m_CharacterSet <> "" Then
m_Mailer.BodyPart.Charset = m_CharacterSet
End If
m_Mailer.To = toEmail
m_Mailer.CC = ccEmail
m_Mailer.BCC = bccEmail
m_Mailer.From = fromEmail
m_Mailer.ReplyTo = fromEmail
m_Mailer.Subject = subject
If m_UseHtmlFormat Then
m_Mailer.HTMLBody = FixText(body)
Else
m_Mailer.TextBody = FixText(body)
End If
Dim i
somefiles = Split(somefiles, vbTab)
For i = 0 to UBound(somefiles)
m_Mailer.AddAttachment(somefiles(i))
Next
m_Mailer.Send
End Sub
I've checked permissions on the mailroot folder and the IIS user has full control. I've already set the relay to 127.0.0.1, and gave the IIS User access to the smtp as well.
When I use telnet I get everything on the log and receive the email correctly.
But even when using this test script I don't get any email, they stay stuck on the pickup folder
Dim emailer
Set emailer = New EmailHelper
emailer.SendEmail "test#test.com", "fede#shocklogic.com", "", "", "Test 1 2 3 from " & Request.ServerVariables("HTTP_HOST"), "Test...", ""
Set emailer = Nothing
Response.Write "DONE"
When I try to execute this test script I always get "DONE" on the page, but no email.
SMTP is already installed and enabled.
Any help would be great
Found the solution! (At least it works for me)
I removed this line
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory")=SMTP_SERVER_PICKUP_DIRECTORY
And configured SMTP in IIS 7 console to use localhost instead of pickup directory and works perfect now!

Classic ASP - Sending Email To Own Domain with CDOSYS fails

I have a classic asp email script that uses authenticated CDOSYS to send to emails from a database. It's running on a Parallels Plesk Windows 2008 server.
This works fine for all email addresses except for any addresses that belong to sites on the server I am sending from.
I could authenticate using a Google Apps email account (the domain is set up using Google Apps for email) BUT I would run up against Google' 24 hour sending limits each time the client ran the script.
Can anyone point out where I'm going wrong or explain why email to sites on the sending server causes an error? The error is
error '8004020f'
/admin/send-group-email.asp, line 128
which is the objCDO.Send line
The Code :
(primarydomain.com is the domain name of the primary account the site lives under in Parallels. The SenderEmail value would be, for example, id#secondarydomain.com)
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "localhost"
.Item(cdoSMTPAuthenticate) = 1
.Item(cdoSendUsername) = "authenticate#primarydomain.com"
.Item(cdoSendPassword) = "thepassword"
.Update
End With
while (NOT RS_Emails.EOF)
Dim objCDO
set objCDO = Server.CreateObject("CDO.Message")
objCDO.Configuration = cdoConfig
objCDO.From = CStr(Request.Form("SenderEmail")) & " (" & CStr(Request.Form("SenderName")) & ")"
objCDO.To = RS_Emails.Fields.Item("email").Value
objCDO.Subject = CStr(Request.Form("Subject"))
objCDO.HTMLBody = message
objCDO.Send
set objCDO = Nothing
RS_Emails.MoveNext
Wend
set cdoConfig=Nothing
This is most likely a server issues which can be solved with Plesk.
Please look at the following link:
http://mkb-training.com/index.php?option=com_content&view=article&id=1:setting-up-google-apps-with-plesk&catid=1:google-tutorial&Itemid=2
Pay attention to the following:
"Uncheck the MX1: "Domain IP also used for mail server"" (there are screenshots there on how to do this). I am not 100% sure about Plesk, but in H-Sphere (another Parallels control panel) doing this is essential for being able to send from the server to your own domain when you have a remote mail exchanger.
Also make sure that no MX records point to your server (even if the Google Apps ones are configured correctly).

Classic ASP, Sending E-mail on windows server 2008 - error '8004020f'

I am trying to send e-mail with classic ASP (I am stuck with an old app so I have to use classic ASP here) on Windows Server 2008 R2, IIS 7.5.
I guess lots of thing change from win server 2003 to 2008. I am using the following code but I am getting this error (BTW, error message is so "informative");
error '8004020f'
/poo.asp, line 32
Here is the code;
<!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%
'Declare variables
Dim sch, cdoConfig, cdoMessage
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail.example.com"
'Set SMTP port which is 25 by default
.Item(sch & "smtpserverport") = 587
.Update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "info#example.com"
.To = "me#example2.com"
.Subject = "Sample CDO Message"
.TextBody = "This is a test for CDO.message"
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
Response.write "<HTML><head><title>A message has been sent.</title></head><body>A message has been sent.</body></HTML>"
%>
Also, I just installed Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1 from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=1004 into my server but it didn't change anything.
NOTE: I could send e-mail over localhost if it works. doesn't matter.
You might come across the following error:
error '8004020f' The event class for this subscription is in an
invalid partition
This error message comes from cdosys.h, and has nothing to do with any sort of "partition" - it is actually lumped in with other errors in an overloaded message. The error code is actually attributed to the following:
CONST LONG CDO_E_RECIPIENTS_REJECTED = 0x8004020FL
Which means that the e-mail was rejected by the server for some reason. Here are some things you can try to alleviate the problem:
Make sure the SMTP server allows anonymous (non-authenticated) relaying. If your SMTP requires outgoing authentication, see Article #2026.
Check if the problem is specific to the domain name(s) used in the e-mail addresses of the recipients. For example, some users have complained that they can send to users on their own domain only; others have said that they can send to any domain except their own (see Article #2511 for some potential causes and solutions).
It may be simply that the e-mail address is being rejected, but other configuration settings on the SMTP server are preventing the true error message from being relayed propely back to the ASP script ... so verify that the address is valid.
If you have a proxy or firewall, make sure the web server is set up to correctly pass through it, that the SMTP server knows about it, and that the proxy allows access to port 25.
Try using a SendUsing value of 1 (pickup) instead of 2 (port). E.g. the following line:
.Item(cdoSendUsingMethod) = cdoSendUsingPort
Becomes
.Item(cdoSendUsingMethod) = cdoSendUsingPickup
http://classicasp.aspfaq.com/email/why-does-cdo-message-give-me-8004020f-errors.html

Resources