I am using classic ASP (I know I should move on to ASP.NET) and a workgroup IIS installation. Can I get it to authenticate to AD? So, far it just won't connect to AD.
It is working on my desktop that is domain joined without any hassles but the same code won't work from the workgroup machine.
Session( "signon_domain" ) = UCase( strSignOnDomain )
Session( "signon_userid" ) = LCase( strSignOnUserID )
' Set the AD path to connect to
strADsPath = "WinNT://" & strSignOnDomain
' Bind to the AD path
Set objADsPath = GetObject( strADsPath )
' Get the namespace
strADsNamespace = "WinNT:"
' Bind to the namespace
Set objADsNamespace = GetObject( strADsNamespace )
' Turn on error handling
On Error Resume Next
' Connect to AD with the provided credentials
Set objADsAuthenticate = objADsNamespace.OpenDSObject( strADsPath, strSignOnDomain & "\" & strSignOnUserID, strSignOnPassword, 0 )
' Check for any errors
If Err.Number <> 0 Then
' Specify the error to display
strMessage = "User ID or password or domain incorrect."
Session( "signon" ) = ""
Else
Session( "signon" ) = "successful"
End If
' Turn off error handling
On Error Goto 0
' Clear variables
Set objADsAuthenticate = Nothing
Set objADsNamespace = Nothing
Set objADsPath = Nothing
strADsNamespace = Empty
strADsPath = Empty
Expecting a response from AD but instead it isn't connecting to AD at all.
Related
We connect ALM using OTA connection library but our company added "2FA" two factor authentication as a security using Symantic VIP access for every outside employee who will access our ALM so what I need now is to add this 2FA authentication in the following previous code to work well as previous.
Private Function TDConnect_ServerConnect(ByVal strServer As String)
On Error GoTo ErrCatch
If (g_objTDC Is Nothing) Then Set g_objTDC = New TDConnection
If (g_objTDC Is Nothing) Then
TDConnect_ServerConnect = TDCONNECT_STATUS_FAIL
Else
g_objTDC.InitConnectionEx strServer
TDConnect_ServerConnect = TDCONNECT_STATUS_PASS
End If
Exit Function
ErrCatch:
TDConnect_Log Err.description, LOG_ERROR
TDConnect_ServerConnect = TDCONNECT_STATUS_FAIL
End Function
we are running SAP BW with BExAnalyzer 7.5. I've been trying for days to establish a connection to the SAP - Server, but unfortunately I am not even receiving an error message. So it seems the logon has succeeded, but no data from BW is fetched, so I am assuming there is a problem in the logon. Please help!
Function LogonToServer() As Boolean
LogonToServer = False
Dim myConnection As Object
Set myConnection = Run("'C:\Program Files (x86)\Common Files\SAP Shared\BW\BExAnalyzer.xla'!SAPBEXgetConnection")
With myConnection
.client = "xxx"
.user = "xxx"
.Password = "xxxx"
.Language = "DE"
.systemnumber = "xxx"
.system = "xxx"
.ApplicationServer = "xxx"
.SAProuter = ""
.Logon 0, True
End With
If myConnection.IsConnected <> 1 Then
'launch the Logon Dialog for manual connection
myConnection.Logon 0, False
If myConnection.IsConnected <> 1 Then
MsgBox "something went wrong ..."
Exit Function
End If
End If
If myConnection.IsConnected = 1 Then
LogonToServer = True
End If
Run "BExAnalyzer.xla!SAPBEXinitConnection"
End Function
SAP Note 2541995 says that the cause is that the Password property is not available in 7.5. It suggests that you can reconnect if you are using Single Sign On (SSO). It also points to note 2635165 that is a front end patch that may fix the issue with the password property. The code you attached does work with version 7.4 and I experienced similar issues with 7.5 but do not have access to download the patch. I'll try and get the front end patch and test again and update my answer with the results.
We are trying to use SAP.NET NCo 3.0 to implement single sign on from .net application to SAP System. In the configuration set up method we are fetching user name and password along with other configuration information from configuration file.
E.g.
RfcConfigParameters rfcConfig = new RfcConfigParameters();
rfcConfig.Add(RfcConfigParameters.User, ConfigurationSettings.AppSettings["SAP_USRNAME"]);
rfcConfig.Add(RfcConfigParameters.Password, ConfigurationSettings.AppSettings["SAP_PWD"]);
rfcConfig.Add(RfcConfigParameters.Client, ConfigurationSettings.AppSettings["SAP_CLIENT"]);
We are looking for a way that we can implement SSO with windows authentication where will ne NO need to pass user id and password explicitly. We also have SNC configuration and other required file available with us.
Any relevant code snippet or pointer addressing this will be of great help.
Thanks in advance
You need to make a http request to the SAP portal from the client. This will give you the SAPSSO2 token (parse it out of the http headers you receive, sample in VB):
Public Function GetSAPSSOTicket(sPortalURL As String, ByRef Ticket As String, ByRef ErrorMsg As String) As Boolean
Dim offset As Long
GetSSOTicket = False
ErrorMsg = ""
Ticket = ""
Const MYSAPSSO2 As String = "MYSAPSSO2="
On Error GoTo Err1
'contact the sap portal
Dim req As New WinHttp.WinHttpRequest
req.Open "GET", sPortalURL, False
req.SetAutoLogonPolicy AutoLogonPolicy_Always
req.Send
Dim S As String
S = req.GetAllResponseHeaders()
'parse the ticket out of the response
offset = InStr(1, S, MYSAPSSO2, vbTextCompare)
If offset <= 0 Then
ErrorMsg = "The Portal Server returned an empty ticket. Authentication failed."
GoSub Cleanup
Exit Function
End If
S = Mid(S, offset + Len(MYSAPSSO2))
offset = InStr(1, S, ";")
S = Left(S, offset - 1)
Ticket = S
'complete
On Error GoTo 0
'success
GoSub Cleanup
GetSSOTicket = True
Exit Function
Cleanup:
Set req = Nothing
Return
Err1:
'some error
GoSub Cleanup
ErrorMsg = Err.Description
End Function
Next, transport this token to your SAP.NET connector code where you make your destination and connection, and assign the value you obtained to the destination's SAPSSO2 property (sample in c#):
var destX = new SAP.Connector.Destination();
destX.Type = "3"; /* meaning R/3 */
destX.AppServerHost = "hostname";
destX.Client = (short)99; /* your client number here */
destX.SystemNumber = (short)42; /* your system number here */
/* single sign-on token passed in from SAPSSO2 header value in sapCookie parameter */
destX.MySAP_SSO2 = System.Web.HttpUtility.UrlDecode(sapCookie, Encoding.UTF8);
destX.Language = "DE";
destX.MsgServerHost = "message server (if needed, otherwise blank)";
destX.LogonGroup = "group name (or blank)";
destX.AbapDebug = false;
destX.Trace = true;
sap.Connection = new SAP.Connector.SAPConnection(destX);
sap.Connection.Open();
We have this code in production since 2004 and it survived many releases, up to and including SAP HANA with Unicode.
I want to get status of a Application Pool. I have vbscript taken from here.
strArgAppPool = Wscript.Arguments.Unnamed.Item(0)
Const noError = False
' Establish the connection to the WMI provider
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Search the AppPool passed as argument in the list of application pools
Set oAppPool = oWebAdmin.Get("ApplicationPool.Name='" & strArgAppPool & "'")
' Create nice messages for pool states
Select Case oAppPool.GetState
Case 0
StateDescription = "STARTING"
outputStatus = "WARNING! "
outputCode = 1
Case 1
StateDescription = "STARTED"
outputStatus = "OK! "
outputCode = 0
Case 2
StateDescription = "STOPPING"
outputStatus = "WARNING! "
outputCode = 1
Case 3
StateDescription = "STOPPED"
outputStatus = "CRITICAL!! "
outputCode = 2
Case 4
StateDescription = "UNKNOWN"
outputStatus = "UNKNOWN? "
outputCode = 3
Case Else
StateDescription = "UNDEFINED VALUE"
outputStatus = "UNKNOWN? "
outputCode = 3
End Select
' Output
Wscript.Echo outputStatus & oAppPool.Name & ": " & StateDescription
' Error handling
If noError = true Then
' Error message
Wscript.echo "UNKNOWN: Error during the WMI query for app pool " & strArgAppPool & " !"
' Exit & return code
WScript.Quit(3)
Else
' Clean exit
WScript.Quit(outputCode)
End If
Through a batch file I am trying to run it as
status1.vbs "DefaultAppPool"
But I ended up with this
Is it some service is not started? I have tried running the vb script directly. I have tried passing arguments without quotes and all similar stuff. I don't write scripts, but got to do it this time.
Error dialog indicates line 5, Set oWebAdmin = GetObject("winmgmts:root\WebAdministration"). I have tried everything I could in last 5 hours. I have a readymade script and I am not able to run it. Shame and was not willing post this question all this while. But lost in end. Thanks for any help.
Also I have a working script for IIS 6. I am calling this script through PsExec on a remote server. But that's not working in IIS 7. Let me know if anyone want me to post it. Also I am using IIS 7 and Server 2008 R2 now and will be running this script using PsExec on remote server.
You don't have the role service IIS Management Scripts and Tools installed. Launch Server Manager, go to Roles → Web Server (IIS), and install the missing service.
I'm working on migrating an application from an IIS 6 to IIS 7.5 and am running into the weirdest issue:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/Complaints/Login.asp, line 175
Here's the code around line 175:
myConn = getDatabaseConnection()
set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Users WHERE lower(Login) = lower('" & uId & "') and Active = 1"
rs.Open strSQL, myConn, 3, 3
Nothing special going on here...
here's the db method:
function getDatabaseConnection()
Dim strConnection
strConnection = "Driver={SQL Server};Server=server.domain.com;Database=cc;uid=acc;pwd=xxx;"
Set GetDatabaseConnection = Server.CreateObject("ADODB.Connection")
GetDatabaseConnection.CommandTimeout = 60
GetDatabaseConnection.ConnectionTimeout = 60
GetDatabaseConnection.CursorLocation = 3
GetDatabaseConnection.Open strConnection
end function
This seems to work in a similar classic asp application running in the same app pool (.NET 1.1)
I've tried: copy pasting the other app's code, using the connection string in place of the db method (throws 500 of course), changing app pools, google, & as another kick it works great on an IIS 6 server.
I took a look at OLE DB Provider for ODBC Drivers Error "80004005' & my connection string seems correct & my ASP.NET 1.1 app pool can only run in 32-bit mode. The DSNs set up on the previous server aren't relevant either.
I have the application working on IIS 5 on domain A and IIS 6 on domain A, but this 7.5 server is on domain B. Thus I'm using the FQDN. I haven't made any other domain specific changes though. The system uses the above method to authenticate users.
Edit: also tried
strConnection = "dsn=my32bitdsn;uid=xxx;pwd=xxx;"
I've inherited this code and am so so with classic ASP, can anybody help?
Updated code:
Dim strConnection, oConn
'get status
set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Users WHERE lower(Login) = lower('" & uId & "') and Active = 1"
'rs.Open strSQL, myConn, 3, 3
strConnection = "Driver={SQL Server};Server=server.domain.com;Database=cc;uid=acc;pwd=xxx;"
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.CommandTimeout = 60
oConn.ConnectionTimeout = 60
oConn.CursorLocation = 3
oConn.Open strConnection
Set rs = oConn.Execute(strSQL)
Might be just cosmetic change, but might solve that issue as well:
Function getDatabaseConnection()
Dim strConnection, oConn
strConnection = "Driver={SQL Server};Server=server.domain.com;Database=cc;uid=acc;pwd=xxx;"
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.CommandTimeout = 60
oConn.ConnectionTimeout = 60
oConn.CursorLocation = 3
oConn.Open strConnection
Set getDatabaseConnection = oConn
End Function
I'm always afraid that using the function name directly will result in unneeded calls or weird results so got used to the above way.
Second thing is that you assign the connection as non object by not having "Set" which also might cause weird and unexpected problems. Change the line to:
Set myConn = getDatabaseConnection()
Hopefully one of the above will solve that weird problem.
I am not sure if you have already solved this error, but if you would like to try and get it to throw a readable error you can try this as part of the connection string.
Your connection string says the db server is server.domain.com or did you just place that there to replace your companies information?
Give this a try:
dim cn
Set cn=Server.CreateObject("ADODB.Connection")
cn.ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=dbName;Data Source=(local) or computername;PWD=;Password=yourpassword;"
on error resume next
cn.Open
if err.number <> 0 then response.Write(err.description)
on error goto 0