Page 1 of 1 1
Topic Options
#180646 - 2007-09-17 09:12 PM Stripping Characters
danilda Offline
Fresh Scripter

Registered: 2006-03-01
Posts: 21
Loc: Washington, DC
I have returned group members using fnldapquery, but only want the user's name. Does anyone know of a way to strip the extraneous data out?

thanks -- dee

Top
#180648 - 2007-09-17 09:31 PM Re: Stripping Characters [Re: danilda]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Show us some code. I think the UDF returns the COM handle, so it should just be a matter of refining the code.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180650 - 2007-09-17 09:41 PM Re: Stripping Characters [Re: danilda]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: CA
As Les said, let us see the code and/or the returned values and we can probably help you better.

SPLIT/JOIN LEFT/RIGHT are some ideas to look at for altering the returned data you want to show or print.

Top
#180723 - 2007-09-19 06:28 PM Re: Stripping Characters [Re: danilda]
danilda Offline
Fresh Scripter

Registered: 2006-03-01
Posts: 21
Loc: Washington, DC
The return code would be CN=James Doe,OU=Users,DC=something,DC=com. I only want the CN name, nothing else.
Top
#180725 - 2007-09-19 06:38 PM Re: Stripping Characters [Re: danilda]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
There are a number of ways to do this, here is one.

 Code:
$="CN=James Doe,OU=Users,DC=something,DC=com"
$CN=right(split($,",")[0],-3)
? $CN
_________________________
(... better days ahead)

Top
#180728 - 2007-09-19 07:04 PM Re: Stripping Characters [Re: Allen]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Indeed, a number of ways
 Code:
Break On
;Declare variables
Dim $Name, $CN
;Initialize variables
$Name = "CN=James Doe,OU=Users,DC=something,DC=com"
;Code
$CN = Split(Split($Name,",")[AScan(Split($Name,","),"CN=",,,1)],"=")[1]
$CN ?

Top
#180730 - 2007-09-19 07:25 PM Re: Stripping Characters [Re: Witto]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Witto,
Never split on a comma, it could be in the name. IMHO, using Split() is a hack. There should be a way to pull just what you want from COM as a specific ADSI property.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180731 - 2007-09-19 07:33 PM Re: Stripping Characters [Re: Les]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
For example:
 Code:
$MyUser = GetObject("LDAP://CN=JamesSmith,OU=MyOrgUnit")
$MyCommonName = $MyUser.Get("CN")
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180732 - 2007-09-19 07:35 PM Re: Stripping Characters [Re: Les]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
or maybe you want:
$MyUser.Get("sAMAccountName")
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180736 - 2007-09-19 07:55 PM Re: Stripping Characters [Re: Les]
danilda Offline
Fresh Scripter

Registered: 2006-03-01
Posts: 21
Loc: Washington, DC
Thanks for all the responses. Using fnldap query attributes to get members of a group. Now can someone tell me how to replacedouble spaces in the middle of the string with one space?
Top
#180737 - 2007-09-19 08:07 PM Re: Stripping Characters [Re: danilda]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
 Code:
Join(split($string,"  ")," ")
_________________________
Today is the tomorrow you worried about yesterday.

Top
#180739 - 2007-09-19 08:18 PM Re: Stripping Characters [Re: Gargoyle]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
 Code:
While instr($string,"  ")
	$string = Join(split($string,"  ")," ")
Loop
_________________________
The Code is out there

Top
#180744 - 2007-09-19 11:07 PM Re: Stripping Characters [Re: DrillSergeant]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Good catch! Had to think about that for a minute..

In case you don't see the reason for the change that DrillSargeant made, consider:

A string with three consecutive spaces would have the first two reduced to one, which would then be joined, resulting in two consecutive spaces - the pair replaced by the single, and the remaining odd (third) space. This would occur if you had any odd number of consecutive spaces above one. The loop keeps checking and reducing double spaces to single spaces.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#180760 - 2007-09-20 03:59 PM Re: Stripping Characters [Re: Glenn Barnas]
danilda Offline
Fresh Scripter

Registered: 2006-03-01
Posts: 21
Loc: Washington, DC
Thanks for everyone's help.

Dee

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 661 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.109 seconds in which 0.069 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org