Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
jgrantham #1
Splitting a CSV list
I have the following type of data in a page and I need to be able to pull each
and every CN value without the CN or anything behind it.
CN=CompStaff,OU=MyOU,DC=MyDC,DC=com,
Is there a way to do this in CF 4.5? I know we are behind times but we are
about to upgrade this year to MX and I ned to be able to do this now. Thaks for
any help you can provide.
jgrantham Guest
-
Splitting a List control into columns
I have the following XML structure as data provider for List control: <?xml version="1.0" encoding="UTF-8"?> <europe> <areas> <area label="West... -
splitting a PDF file
Does anyone know if or how to split a multiple page PDF file into single page PDF files in Acrobat 7? I heard this could be done without purchasing... -
Intelligent PDF Splitting
Does anyone have information about intelligent PDF splitting, using either command line or applescript? -
Splitting Comma delimited list
Hello everyone, I use the following to split a comma delimited list and get varying results and I don't understand why. my count of the... -
Splitting OR Regex
On Thu, 30 Oct 2003 23:37:55 -0500, Scott, Joshua wrote: This is a FAQ: perldoc -q delimit -- Tore Aursand <tore@aursand.no> -
blewis #2
Re: Splitting a CSV list
I can't remember, does 4.5 not support RegEx? I assume not, so you would have
to loop:
<cfset aMyCNs = ArrayNew(1)>
<cfset foo = "CN=CompStaff,OU=MyOU,DC=MyDC,DC=com,">
<cfloop index="i" list="#foo#" delimiter=",">
<cfif Left(i, 3) IS "CN=">
<cfset x = ArrayAppend(aMyCNs, ReplaceNoCase(i, "CN=", ""))>
</cfif>
</cfoop>
You end up with an array of your CNs. You could use a list instead.
blewis Guest
-
OldCFer #3
Re: Splitting a CSV list
This would work:
<cfset TheStr = "CN=CompStaff,OU=MyOU,DC=MyDC,DC=com,CN=MyStaff,CN =YourStaff">
<cfloop index="ii" list="#TheStr#">
<cfif NOT Compare("CN",ListFirst(ii,"="))>
<cfoutput>The DC value is #ListLast(ii,"=")#<br></cfoutput>
</cfif>
</cfloop>
OldCFer Guest
-
jgrantham #4
Re: Splitting a CSV list
Your solution is REAL close to what I want.
I am running a CFLDAP query named "Groups" where it searches for the groups a
person belongs to based on a variable submitted to the page thus the
#Groups.memberOf#. It seems to be listing only the first one or two groups
this person belongs to. Any ideas on how to make it work? I'm REAL new to CF
and havae this project that needs to be done and this is all that is holding me
back.
Here is the code after modifying it for my situation:
<cfset TheStr = "#Groups.memberOf#">
<cfloop index="ii" list="#TheStr#">
<cfif NOT Compare("CN",ListFirst(ii,"="))>
<td align="left" width="30%">#ListLast(ii,"=")#</td><br>
</cfif>
</cfloop>
jgrantham Guest
-
jgrantham #5
Re: Splitting a CSV list
Here is the output I'm getting if I just do a #Groups.memberOf# :
CN=Computer Staff dummyOffice,OU=Distribution
Lists,OU=dummyOffice,DC=dummy,DC=com,
CN=eCopyScanner,OU=dummyOffice,DC=dummy,DC=com, CN=Antigen
dummyOffice,OU=Distribution Lists,OU=dummyOffice,DC=dummy,DC=com,
CN=JaxCompStaff,OU=dummyOffice,DC=dummy,DC=com, CN=Docs
Users,CN=Users,DC=dummy,DC=com, CN=AV,OU=dummyOffice,DC=dummy,DC=com,
CN=P10TRNG,OU=dummyOffice,DC=dummy,DC=com, CN=Personnel Update,OU=Distribution
Lists,OU=dummyOffice,DC=dummy,DC=com, CN=OWA Secure
users,CN=Users,DC=dummy,DC=com, CN=CMS BASIC,OU=CMS,DC=dummy,DC=com,
CN=SpyBot,OU=dummyOffice,DC=dummy,DC=com,
CN=Verizon,OU=dummyOffice,DC=dummy,DC=com, CN=Jackson Backup,OU=Distribution
Lists,OU=dummyOffice,DC=dummy,DC=com, CN=Computer Staff
All,OU=dummyOffice,DC=dummy,DC=com
How can I sort through this and just pull the values after CN= without the OU
and DC values? This is what I'm trying to do. The code submitted above only
list two groups but as you can see, there are a lot more than that.
jgrantham Guest
-
eastinq #6
Re: Splitting a CSV list
How about this:
<cfset TheStr = "#Groups.memberOf#">
<cfloop index="ii" list="#TheStr#">
<cfif ii contains "CN=">
<td align="left" width="30%">#Replace(ii,"CN=","")#</td>
</cfif>
</cfloop>
eastinq Guest
-
jgrantham #7
Re: Splitting a CSV list
That's a little closer. I now get the whole list of groups for the user but
they are all in a straight line. Any ideas now on how to get it to put each one
on a seperate line inside a table? The internals of the table are already
inside a cfoutput tag so I don;t think I could nest them could I?
Here is the code I have already for the table:
<table border=0 cellspacing=2 cellpadding=2 width="100%">
<cfoutput query="results">
<tr>
<th colspan="4" align="center"><font color="336600"><b>Active Dirctory
Information for: #displayName#</b></font></th>
</tr>
<tr>
<td width="100%" colspan="4"><hr width="100%"></td>
</tr>
<tr>
<td width="22%" align="right"><font color="336600"><b>Distinguished Name:
</b></font></td>
<td colspan="4"><font color="black">#dn#</font></td>
</tr>
<tr>
<td width="22%" align="right"><font color="336600"><b>Account
Created:</b></font> </td>
<cfset AccCreatedYear = Left(whenCreated,4)>
<cfset AccCreatedMonth = Mid(whenCreated,5,2)>
<cfset AccCreatedDay = Mid(whenCreated,7,2)>
<td colspan="4"><font color="black">#MonthAsString(AccCreatedMonth)#
#AccCreatedDay#, #AccCreatedYear#</font></td>
</tr>
<tr>
<td width="22%" align="right"><font color="336600"><b>Account
Changed:</b></font> </td>
<cfset AccChangedYear = Left(whenChanged,4)>
<cfset AccChangedMonth = Mid(whenChanged,5,2)>
<cfset AccChangedDay = Mid(whenChanged,7,2)>
<td colspan="4"><font color="black">#MonthAsString(AccChangedMonth)#
#AccChangedDay#, #AccChangedYear#</font></td>
</tr>
<tr>
<td width="100%" colspan="4"><hr width="100%"></td>
</tr>
<tr>
<td align="right" width="22%"><font color="336600"><b>User
ID:</b></font></td>
<td align="left" width="30%"><font color="black">#sAMAccountName#</font></td>
<td align="right" width="22%"><font
color="336600"><b>Description:</b></font></td>
<td align="left" width="30%"><font color="black">#Description#</font></td>
</tr>
<tr>
<td align="right" width="22%"><font
color="336600"><b>Department:</b></font></td>
<td align="left" width="30%"><font color="black">#Department#</font></td>
<td align="right" width="22%"><font color="336600"><b>Telephone
Number:</b></font></td>
<td align="left" width="30%"><font
color="black">#telephoneNumber#</font></td>
</tr>
<tr>
<td width="100%" colspan="4"><hr width="100%"></td>
</tr>
<tr>
<td align="right" width="22%"><font color="336600"><b>Account
Locked:</b></font></td>
<td align="left" width="30%"><cfif #lockoutTime# EQ "0"><font
color="black">No</font><cfelse><font color="red">Yes</font></font></cfif></td>
<td align="right" width="22%"><font color="336600"><b>Account
Disabled:</b></font></td>
<td align="left" width="30%"><cfif #userAccountControl# EQ "512"><font
color="black">No</font><cfelse><font color="red">Yes</font></font></cfif></td>
</tr>
<tr>
<td align="right" width="22%"><font color="336600"><b>Bad
Logins:</b></font></td>
<td align="left" width="30%"><cfif #badPwdCount# EQ "0"><font
color="black">#badPwdCount#</font><cfelse><font
color="red">#badPwdCount#</font></cfif></td>
<td align="right" width="22%"><font color="336600"><b>Max/Attempts
Left:</b></font></td>
<td align="left" width="30%"><font
color="black">#lockoutThreshold#</font></td>
</tr>
<tr>
<td width="100%" colspan="4"><hr width="100%"></td>
</tr>
<tr>
<td align="right" width="22%"><font color="336600"><b>Home
Directory:</b></font></td>
<td align="left" width="30%"><font color="black">#HomeDirectory#</font></td>
<td align="right" width="22%"><font color="336600"><b>Home
Drive:</b></font></td>
<td align="left" width="30%"><font color="black">#homeDrive#</font></td>
</tr>
<tr>
<td align="right" width="22%">Member Of:</td>
<cfset TheStr = "#Groups.memberOf#">
<cfloop index="ii" list="#TheStr#">
<cfif ii contains "CN=">
<td align="left" width="30%">#Replace(ii,"CN=","")#<br></td>
</cfif>
</cfloop>
</tr>
</cfoutput>
</table>
jgrantham Guest
-
jgrantham #8
Re: Splitting a CSV list
I FINALLY DID IT!!!! Hope this helps someone else down the road. Here is the
solution:
<tr>
<td align="right" width="22%" valign="top"><font color="336600"><b>Member
Of:</b></font></td>
<td width="30%" align="left">
<table width="100%">
<cfset TheStr = "#Groups.memberOf#">
<cfloop index="ii" list="#TheStr#">
<cfif ii contains "CN=">
<tr>
<td align="left" width="30%"><font
color="black">#Replace(ii,"CN=","")#</font></td>
</tr>
</cfif>
</cfloop>
</table>
</td>
</tr>
jgrantham Guest
-
jgrantham #9
Re: Splitting a CSV list
Sorry! I had to nest another table inside the <td> tag to get it to wrap the group names to a new line for every group.
jgrantham Guest



Reply With Quote

