Page 1 of 1 1
Topic Options
#149495 - 2005-10-07 06:57 PM LDAP query
Amaro Offline
Lurker

Registered: 2005-10-07
Posts: 4
Hello; I found script online which will allows me to query an OU and get the list of users, which I getting but since in this company uses nj2334894783 as user ID. I got a list of user IDs but don't know who they are.

Can someone help me enter missing code to get the user name and last name?



Dim $Filter[0]
$Filter[0]="Group" ; Or replace "Group" with "User" or "Computer"

$ou = GetObject("LDAP://cn=users,dc,test,dc=local")
$ou.Filter = $Filter

For Each $UserOrGroupOrComputer in $ou
? $UserOrGroupOrComputer.Name
Next

Top
#149496 - 2005-10-07 07:44 PM Re: LDAP query
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
You can use displayName but if it's not filled out then it will come back blank.

Might be better to use givenName and SN

Top
#149497 - 2005-10-07 07:47 PM Re: LDAP query
Amaro Offline
Lurker

Registered: 2005-10-07
Posts: 4
thanks, But how exacly will I add the code ..
Sorry I just started using it/learning scripting

Top
#149498 - 2005-10-07 07:52 PM Re: LDAP query
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well if this is working, then you should be able to do this.

For Each $UserOrGroupOrComputer in $ou
  ? $UserOrGroupOrComputer.Name
Next

 
For Each $UserOrGroupOrComputer in $ou
   ? $UserOrGroupOrComputer.SN
   ? $UserOrGroupOrComputer.givenName
Next
 

Top
#149499 - 2005-10-07 08:11 PM Re: LDAP query
Amaro Offline
Lurker

Registered: 2005-10-07
Posts: 4
Wow that was awesome ... the only problem is that get:
User
User
givenName
givenName
for 500 users

Is there a way to get the output be
User,givenName

so I can match userID with user fullname?

Thanks

Top
#149500 - 2005-10-07 08:41 PM Re: LDAP query
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well untested and NOT the most efficient code, but so that you can see output, maybe something like this.

You should really take the time though and read up on scripting so that you better understand what you're trying to do. There are also some great UDFS designed to do a lot of this for you.

Code:
For Each $UserOrGroupOrComputer in $ou 
Dim $FullName
$FullName = $UserOrGroupOrComputer.givenName + ' ' + $UserOrGroupOrComputer.SN
'Full name for: ' + $UserOrGroupOrComputer.Name + ' is: ' + $FullName
Next


 

Top
#149501 - 2005-10-08 06:04 AM Re: LDAP query
Amaro Offline
Lurker

Registered: 2005-10-07
Posts: 4
Thanks, can you recoment or point me to the reading material?
I would really apreciate it.

Top
#149502 - 2005-10-08 06:24 AM Re: LDAP query
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well reading the manual that ships with KiXtart is a good start, but then take a look at the FAQ forum here on the board.

http://www.kixtart.org/ubbthreads/postlist.php?Cat=0&Board=UBB10

As you learn KiXtart some, you'll soon be able to get into doing the COM calls a lot easier.

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 1046 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.057 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

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