Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: ADSI results - sorting problem


Message #1 by charalyi@n... on Thu, 19 Sep 2002 15:53:28
HELLO ALL,

I use the following code to read the values of an multivalue field.
I get the results but they are unsorted.
Does any one know how can i sort them?

Thanks in advanced.

<%
On Error Resume Next
Set objUser = GetObject _
  ("LDAP://cn=my name,ou=users,dc=domainname,dc=GR")
objUser.GetInfo


strDirectReports = _
  objUser.GetEx("directReports")


For Each strValue in strDirectReports

	iPos = InStr(strValue , "CN=")
	s1UserTEMP = Mid(strValue , iPos + 3)

	IPOSNEW = INSTR(S1USERTEMP,",")
	S1USERTEMP1 = LEFT(S1USERTEMP, IPOSNEW -1)

	RESPONSE.WRITE "directReports: " & S1USERTEMP1 & "<BR>"

Next
%>
Message #2 by "Chris Thompson" <cthompson@n...> on Thu, 19 Sep 2002 08:51:57 -0600
I had the same problem.  Since our network is not too big (200 PC's), I
just loaded the results into a string separated by commas, then split
them into an array.  I then looped through the array checking 2 elements
at a time and if the first was greater than the second, I switched them
and set a flag.  I looped through it until the flag was never set
meaning it got through the list and it was all in order.

Thanks,

Chris Thompson

-+-+-+-+-+-+-+-+-+-+-+-
cthompson@n...
xxx-xxx-xxxx
-+-+-+-+-+-+-+-+-+-+-+-



-----Original Message-----
From: charalyi@n... [mailto:charalyi@n...]
Sent: Thursday, September 19, 2002 9:53 AM
To: ASP Web HowTo
Subject: [asp_web_howto] ADSI results - sorting problem

HELLO ALL,

I use the following code to read the values of an multivalue field.
I get the results but they are unsorted.
Does any one know how can i sort them?

Thanks in advanced.

<%
On Error Resume Next
Set objUser =3D GetObject _
  ("LDAP://cn=3Dmy name,ou=3Dusers,dc=3Ddomainname,dc=3DGR")
objUser.GetInfo


strDirectReports =3D _
  objUser.GetEx("directReports")


For Each strValue in strDirectReports

	iPos =3D InStr(strValue , "CN=3D")
	s1UserTEMP =3D Mid(strValue , iPos + 3)

	IPOSNEW =3D INSTR(S1USERTEMP,",")
	S1USERTEMP1 =3D LEFT(S1USERTEMP, IPOSNEW -1)

	RESPONSE.WRITE "directReports: " & S1USERTEMP1 & "<BR>"

Next
%>

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20
Message #3 by Imar Spaanjaars <Imar@S...> on Thu, 19 Sep 2002 17:05:59 +0200
Another quick heck to sort the items is to load them in an ADODB Recordset. 
A recordset has sorting capabilities, so there's no need to write your own 
sorting routines.

You'll need ADO on the machine, though.

Cheers,

Imar




At 08:51 AM 9/19/2002 -0600, you wrote:
>I had the same problem.  Since our network is not too big (200 PC's), I
>just loaded the results into a string separated by commas, then split
>them into an array.  I then looped through the array checking 2 elements
>at a time and if the first was greater than the second, I switched them
>and set a flag.  I looped through it until the flag was never set
>meaning it got through the list and it was all in order.
>
>Thanks,
>
>Chris Thompson
>
>-+-+-+-+-+-+-+-+-+-+-+-
>cthompson@n...
>xxx-xxx-xxxx
>-+-+-+-+-+-+-+-+-+-+-+-
>
>
>
>-----Original Message-----
>From: charalyi@n... [mailto:charalyi@n...]
>Sent: Thursday, September 19, 2002 9:53 AM
>To: ASP Web HowTo
>Subject: [asp_web_howto] ADSI results - sorting problem
>
>HELLO ALL,
>
>I use the following code to read the values of an multivalue field.
>I get the results but they are unsorted.
>Does any one know how can i sort them?
>
>Thanks in advanced.
>
><%
>On Error Resume Next
>Set objUser = GetObject _
>   ("LDAP://cn=my name,ou=users,dc=domainname,dc=GR")
>objUser.GetInfo
>
>
>strDirectReports = _
>   objUser.GetEx("directReports")
>
>
>For Each strValue in strDirectReports
>
>         iPos = InStr(strValue , "CN=")
>         s1UserTEMP = Mid(strValue , iPos + 3)
>
>         IPOSNEW = INSTR(S1USERTEMP,",")
>         S1USERTEMP1 = LEFT(S1USERTEMP, IPOSNEW -1)
>
>         RESPONSE.WRITE "directReports: " & S1USERTEMP1 & "<BR>"
>
>Next
>%>



  Return to Index