[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

query a subdomain in CFLDAP using AD?

Asked by exhudson in Cold Fusion Markup Language, ColdFusion Application Server, ColdFusion Studio

Tags: ColdFusion, Active Directory, LDAP, query

Folks,
I have a working cfldap query that I now need to get to search in a subdomain. Even though the scope=SUBTREE, it does not see to go there. So, I tried nesting the queries- do the first one, if that doesn't work, then do the second one. It still doesn't work.

What it does is check if a user can login to AD using an LDAP call, if it can, then go on, if it cant, set some flags and go to error page.
The original one worked fine, but I am trying to check for the subdomain of "childsupport" since the query does not seem to travel that far down.

Is there a simple way to do this? Or is my problem in calling one cfscript after another? Is the cftcatch making it not work? help!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
<cfscript>
 //<!--- setting basic LDAP server attributes --->
start="DC=county,DC=*****,DC=net"; 
servername = "server.blah.net";
port = "389"; attributes="cn,password,uid,dn,givenName,sn,edupersonaffiliation,title,physicalDeliveryOfficeName,homePhone,displayName,department,mail,employeeid"; 
 //<!--- passing the username and password that captured from the form ---> 
  //<!--- this filter will look in the objectclass for the user's ID ---> 
 filter="(&(objectclass=user)(SamAccountName=#fname#))";
</cfscript> 
<!--- pass the user's DN and password to see if the user authenticates --->   
<cftry>
	<cfldap action="QUERY"
	name="results2"
	attributes="#attributes#"
	start="#start#"
	scope="SUBTREE"
	filter="#filter#"
	server="#servername#"
	port="#port#"
	username="#fName#@***.net"
	password="#fPass#">
<cfcatch type="any">
					
<!--- 		Try another domain --->
<cfscript>
	
start="OU=Users,OU=Department,DC=childsupport,DC=county,DC=****,DC=net"; 
servername = "server.blah.net";
 port = "389";
 //<!--- Attributes must include uid and dn.  These are used within the 2 authorization queries. ---> 
attributes="cn,password,uid,dn,givenName,sn,edupersonaffiliation,title,physicalDeliveryOfficeName,homePhone,displayName,department,mail,employeeid"; 
 //<!--- passing the username and password that captured from the form ---> 
										   
//<!--- this filter will look in the objectclass for the user's ID ---> 
										   filter="(&(objectclass=user)(SamAccountName=#fname#))";
</cfscript> 
<!--- pass the user's DN and password to see if the user authenticates --->   
		<cftry>
		<cfldap action="QUERY"
name="results2"
		attributes="#attributes#"
		start="#start#"
		scope="SUBTREE"
		filter="#filter#"
		server="#servername#"
		port="#port#"
		username="#fName#@****net"
		password="#fPass#">
						
	<cfcatch type="any">
									
												<cfcookie name="UserAuth" value=false>
							
													<cfset myResult=false>
													<cfif urlLoc NEQ "flash">
							
														 <cfif find("?",#HTTP_REFERER#) EQ 0>
															<cfoutput> <cflocation url="#HTTP_REFERER#?result=#myResult#" addtoken="no"></cfoutput>
														 <cfelse>
															 <cfset newLen = len(#HTTP_REFERER#) - 13>
															<cfset newURL = LEFT(#HTTP_REFERER#,#newLen#)>
																<cfoutput> 
																	#newURL#
																	<cflocation url="#newURL#?result=#myResult#" addtoken="no">
																</cfoutput> 
														 </cfif> 
													</cfif>
										</cfcatch>
								 </cftry>
						 </cfcatch>
				 </cftry>
				
							   
			   
			 
			   
<!--- 			   ----------------------------------------- --->
			   
			<!--- If the userID and password are valid --->
				 <cfif #results2.recordcount#>
					<cfset myResult=true>
					<cfif urlLoc NEQ "flash">
					<!---Find the user in the adminUsers table--->
		<cfoutput>
		<cfquery name="getUsers" datasource="#application.passdsn#">
		Select * from pass_admin_users where user_name = '#fName#' 
		</cfquery>
[+][-]08/24/09 04:15 PM, ID: 25173408Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/30/09 11:06 AM, ID: 25705435Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/16/09 07:33 AM, ID: 25830938Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625