Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ping to see if I can connect to a server

Status
Not open for further replies.

evergreean43

Technical User
May 25, 2006
165
0
0
US
I have links on my CF 6.1 MX page on Windows Server but some people cant access the server the links are on because they dont have access to that server. But there are people that do have access to that server.

I would like to have a message that shows "Page not accessible to your ID" if the user doesnt have access to that server.

Here is what I think I can do but need alot of help:
Code:
<cfexecute name = "C:\winnt\system32\ping.exe"
  arguments="dnsNameOfServerIwantToPing"
>
</cfexecute>

<cfif not ??pingissuccessful??>
   <cflocation url="CantAccessPage.cfm">
</cfif>
 
????If people don't have access to this server, how are you going to run this code for them???? The people have to connect to the server before the CF code can run, so if they can't connect to the server, the CF code can't run for them.

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
On a web page sitting on a common server which everyone has access to there are links that link out to another server which some people can not access.

That is what I want to check.
 
But it still doesn't have anything to do with the ColdFusion server. The CF Server has no knowledge of your users or what they can and can't get to. You can set up a ping like this, but it's only going to tell you if the CF Server can ping the servers in question, not each indivual user on your website. So, it will either return "Yes" for EVERY user on your website, or "No" for EVERY user on your website. There will be no variation.

Now, if you have a way to find out who has permission to access what, then you can just stick that in a database and have CF reference that in the links.

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
No. ECAR, you are forgetting the ping will run from the client computer, not from the CFServer. Of course then you have to have some way of detecting the error and that would require a client side script in something like JavaScript. Have you tried looking for a JavaScript to test pings?

DonOmite
 
Really?? I can only imagine the kind of havoc i could wreak if I could call executables on client computers. I'm not an authority on the matter having never used cfexecute myself, but that does not seem right.

=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
and on another note, if that were possible to do this - you can use the 'variable' attribute to grab the program output.

=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
If the CF Server is executing a program at "C:\winnt\system32\ping.exe", it will be executed on the server.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
It doesn't make any sense to show a link that doesn't work; show it only if the user can go there.

Here's a neat VBScript that uses LDAP to determine group membership of the logged-in user. You can replace the sUserID value with the HTTP.AUTH_USER info (I assume that your Web server is running under authentication; if not, you're hosed). From there, compare to a list of groups that have access to the server, and display ONLY the links for which the user has access.

'************************************************************
'INGROUP function
'
' Thanks in part to Microsoft's site, and to Richard Mueller
'
' This function simply returns the groups that a particular
' user, regardless of OU membership belongs. Function can
' be modified to build an array, and to check whether or
' not the function has already run once in the script. If
' it has the query to AD can be avoided a second time around.
'
'*************************************************************


'Create connection and command object
Set con = CreateObject("ADODB.Connection")
Set com = CreateObject("ADODB.Command")


'Opening the connection
con.Provider = "ADsDSOObject" 'this is the ADSI OLE-DB provider name
con.Open "Active Directory Provider"


'Create a command object for this connection
Set Com.ActiveConnection = con


'Get DC
Set oRoot = GetObject("LDAP://RootDSE")
dcString = oRoot.Get("DefaultNamingContext")


'Get current user (Assuming Windows NT/Windows 2000 Only!)
Set oNet = CreateObject("Wscript.Network")
sUserID = oNet.UserName


'Compose a search string
sQuery = "SELECT distinguishedName from 'LDAP://" & dcString
sQuery = SQuery & "' WHERE sAMAccountName = '" & sUserID & "'"


com.CommandText = sQuery


'Execute the query
Set rs = Com.Execute


'Populate the relative path
ouString = rs.Fields("distinguishedName")


WScript.Echo "** Displaying Groups **"


Set oUser = GetObject("LDAP://" & ouString)


' Here is where you can populate a "Groups" array and flag to not query
' AD again.
' But this function just displays the groups, SANS the "DC="


For Each oGroup In oUser.Groups
WScript.Echo Right(oGroup.Name,Len(oGroup.Name)-3)
Next


'Housecleaning
Set oNet = Nothing
Set oRoot = Nothing
Set rs = Nothing
Set oGroup = Nothing
Set oUser = Nothing
'*********************************************

Have Fun!

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Yes, it COULD run it from the server. Depends on how it is written.

And yes, you CAN run exectutables on client computers IF their security allows you to.

I've done that before but only on intranet sites where the security allowed it for specific cases.

But for a client to know if it can connect to a site it has to run the ping, not the server. (Yes, there are better ways to do this).

One better way is to capture the error when the user tries to go to the site and gets told "No". Then redirect.

OR use Phil's solution.

OR use authentication right off the bat when they login and modify the pages to show the proper information.

Calling a ping is probably the last resort.

DonOmite
 
Thanks for all the info!

Our web server is not and will not run under authentication.


I assume the below is put on the actual page with the error and if so how would I redirect??

One better way is to capture the error when the user tries to go to the site and gets told "No". Then redirect.
 
I assume the below is put on the actual page with the error and if so how would I redirect??

One better way is to capture the error when the user tries to go to the site and gets told "No". Then redirect.

You can't do that, it's physically impossible.

For the redirect to work, the server needs to reply to their request. If they cannot ping the server because it is not accessible from their machine, there is absolutely no way the server can answer the request to redirect them.

Hope this helps

Wullie

YetiHost - Quality Coldfusion 7/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
You could run a Javascript HTTP call (or CFHTTP) to the doc server and evaluate the results for the 401 text. Pop up a message box if the link doesn't work; run a .location (or CFLOCATION) if it does.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
You could run a Javascript HTTP call (or CFHTTP) to the doc server and evaluate the results for the 401 text. Pop up a message box if the link doesn't work; run a .location (or CFLOCATION) if it does.

How can you run CFHTTP? That runs on the server and has absolutely no way of telling you what the client can or cannot access. The only way that would work would be to install CF on every client machine just so you could use CFHTTP.

Hope this helps

Wullie

YetiHost - Quality Coldfusion 7/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Thanks,

I see the common answer that this is server side.

I appreciate all the information!
 
You keep thinking coldfusion. Obviously the server side script will only work if nobody can get there.

However, I'm thinking client side scripting such as JS, VBS, maybe even CFS.

I'm sure some JS guru could write up something that would detect what the result of clicking on a link is.

Probably have to open the page in a frame to do it tho.



DonOmite
 
Well, I think we had already established it had to be client side which rules out CF.

And actually there might be a way to do it with CF, but it would be very roundabout with frames. Basically one page checking another page.

Probably more trouble than it is worth tho.

DonOmite
 
I am going to look into client side and all your suggestions help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top