Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

How would I translate CFLOCK tag to a php tag?

I am translating a coldfusion page the has "CFLOCK" in it and don't know how to translate it, how would I do this?
<cflock scope="session" type="exclusive" timeout="3">
      <cfparam name="session.sut" default="Unlisted NONE AP">
</cflock>
<cflock scope="server" type="exclusive" timeout="3">
      <cfset SERVER = #cgi.SERVER_NAME#>
</cflock>
0
lhaluska
Asked:
lhaluska
  • 5
  • 3
1 Solution
 
DigitalTyrantCommented:
Although I am unfamiliar with it's use, PHP has an flock function.  Documentation available at http://us2.php.net/manual/en/function.flock.php.

Good Luck!
0
 
lhaluskaAuthor Commented:
The code I had posted could it be php session? How do sessions work?
<cfapplication name="serviceRequest" sessionmanagement="Yes" setclientcookies="Yes">
<cflock scope="session" type="exclusive" timeout="3">
      <cfparam name="session.sut" default="Unlisted NONE AP">
</cflock>
<cflock scope="server" type="exclusive" timeout="3">
      <cfset SERVER = #cgi.SERVER_NAME#>
</cflock>
0
 
Scott BennettManager TechnologyCommented:
You do not have to specifically lock the session scope in php, it does that automatically.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Scott BennettManager TechnologyCommented:
here's a good explainatino of how locking works in php and how you can use session_write_close() if you have a need to multiple requests on one session to run concurrently.

http://us2.php.net/manual/en/ref.session.php#64525
0
 
lhaluskaAuthor Commented:
Can a session a ntuserdomainid? My code is trying to get this as a variable but I don't know how.
<cfapplication name="serviceRequest" sessionmanagement="Yes" setclientcookies="Yes">
<cflock scope="session" type="exclusive" timeout="3">
      <cfparam name="session.sut" default="Unlisted NONE AP">
</cflock>
<cflock scope="server" type="exclusive" timeout="3">
      <cfset SERVER = #cgi.SERVER_NAME#>
</cflock>
<!--- Need a var to break the loop. --->
<cfset Foobar = false>
<cflock scope="server" type="readonly" timeout="3">
<cfset ntUserDomainId = "#Replace("#AUTH_USER#","\",":")#">
</cflock>            
<cfset Identified = false>
<cflock scope="session" type="readonly" timeout="5">
      <cfif IsDefined("session.routeTo") AND Len("session.routeTo") GT 0>
            <cfset Identified = true>
      </cfif>
</cflock>
<cfif Identified is false>0
<cftry>
<cfldap action="QUERY"
name="UserData"
attributes="sn,givenname,telephonenumber,manager,ntUserDomainId,cupJobTitle,ou,uid,EMPLOYEENUMBER,managerEMPLOYEENUMBER,cn,mailRoutingAddress"
start="o=cup.com"
scope="SUBTREE"
filter="ntUserDomainId=#ntUserDomainId#"
server="ldap.cce.cup.com"
port="389">
<cfcatch>
0
 
Scott BennettManager TechnologyCommented:
Your coldfusion code is a little unorthodox.
First of all there is not a reason to lock the server scope on the line:
<cflock scope="server" type="exclusive" timeout="3">
      <cfset SERVER = #cgi.SERVER_NAME#>
</cflock>

and you should not name a variable "server" in the first place that would be like naming a variable <cfset form = "something"> you just don't do that.

also on the line:

<cflock scope="server" type="readonly" timeout="3">
<cfset ntUserDomainId = "#Replace("#AUTH_USER#","\",":")#">
</cflock>  

The lock is not neccessary as you are not updating or reading anything in the server scope.

Beyond the starnge use of cflock on the server scope, your coldfusion code appears to be attempting to query an LDAP server for employee information based on the "domain.username" that they used to log into the site with.
0
 
lhaluskaAuthor Commented:
Yes that is correct. So what I think I need to replace the coldfusion code is a way the authticate the NTuser.
0
 
lhaluskaAuthor Commented:
What I am trying to do is to find how to get the "ntUserDomainId" variable. How would I get that info from the user?
0
 
lhaluskaAuthor Commented:
So I found that if I use "$ntUserDomainId = $_SERVER['AUTH_USER'];" I can get the users windows logon info. But how do I and this ""#Replace("#AUTH_USER#","\",":")#"" to the variable to replace the / or \ to a : .
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now