Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


I need some LDAP help...

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,34730
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> I need some LDAP help...
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 I need some LDAP help... - 5/19/2006 3:39:32 AM   
  BDIntern

 

Posts: 34
Score: 0
Joined: 5/19/2006
Status: offline
We are doing some Active Directory cleanup. When a user is terminated we add "LDW" (last day worked) followed by the date, in the "Description" field. I'm new at scripting, and would like to be pointed in the right direction.

So far I have a script that will echo the contents of the description field of all users in an ou:

set objOU= GetObject("LDAP://ou=Test,ou=company,dc=usa,dc=com")
   For each objItem in objOU
       Wscript.echo objItem.Description
Next

What I need it do do is search the entire ou for users with "LDW" in the description field and output the results in a spread sheet.

Any help would be much appreciated.


_____________________________

"640k ought to be enough for anybody"
-Bill Gates
 
 
Post #: 1
 
 RE: I need some LDAP help... - 5/19/2006 4:25:20 AM   
  Country73


Posts: 735
Score: 10
Status: offline
This may work out for you:

set objOU= GetObject("LDAP://ou=Test,ou=company,dc=usa,dc=com")
For each objItem in objOU
   'Wscript.echo objItem.Description
    If InStr(objItem.Description,"LDW")Then
        wscript.echo objItem.Description
    End If
Next

(in reply to BDIntern)
 
 
Post #: 2
 
 RE: I need some LDAP help... - 5/19/2006 4:47:22 AM   
  BDIntern

 

Posts: 34
Score: 0
Joined: 5/19/2006
Status: offline
Thanks, that worked perfectly to echo it. I just need it now to write what it echoed to a file.

I inserted this:

Dim OutPutFile
Dim FileSystem
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("LDW_GeoffTest.xls", True)
set objOU= GetObject("LDAP://ou=Test,ou=company,dc=usa,dc=com")
For each objItem in objOU
  'Wscript.echo objItem.Description
   If InStr(objItem.Description,"LDW")Then
       OutPutFile.WriteLine objRecordset.Fields("Description").value
   End If
Next

The error I get is:

Line: 11
Char: 9
Error: Object required: 'objRecordset'
Code: 800A01A8

I can't seem to find the problem

_____________________________

"640k ought to be enough for anybody"
-Bill Gates

(in reply to Country73)
 
 
Post #: 3
 
 RE: I need some LDAP help... - 5/19/2006 5:03:04 AM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi BDIntern,

there is no variable "objRecordset" in your script. (If you had
put "Option Explicit" at the top, VBScript would have told you
that.)

  OutPutFile.WriteLine objRecordset.Fields("Description").value

==>
 
  OutPutFile.WriteLine objItem.Description

(in reply to BDIntern)
 
 
Post #: 4
 
 RE: I need some LDAP help... - 5/19/2006 5:09:24 AM   
  BDIntern

 

Posts: 34
Score: 0
Joined: 5/19/2006
Status: offline
Thank you!

_____________________________

"640k ought to be enough for anybody"
-Bill Gates

(in reply to ehvbs)
 
 
Post #: 5
 
 RE: I need some LDAP help... - 5/22/2006 2:12:25 AM   
  BDIntern

 

Posts: 34
Score: 0
Joined: 5/19/2006
Status: offline
Ok so here is an update on my situation. I've got the code working for a specific ou, but if I run the script against one ou, it will not check the sub-ou's. How do I do that?

Here is the script so far:

Dim OutPutFile
Dim FileSystem
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("LDW_Test.xls", True)
set objOU= GetObject("LDAP://ou=Test Users,ou=Towson,dc=Company,dc=com")
For each objItem in objOU
   If InStr(objItem.Description,"LDW")Then
OutPutFile.WriteLine objItem.Description & " " & objItem.sAMAccountName & " " & objItem.displayName
   End If
Next

_____________________________

"640k ought to be enough for anybody"
-Bill Gates

(in reply to BDIntern)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> I need some LDAP help... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts