Return to Snippet

Revision: 40533
at February 3, 2011 06:55 by lance


Initial Code
Set oRootDSE = GetObject("LDAP://RootDSE") 
Set Conn = CreateObject("ADODB.Connection") 
Set Comm =   CreateObject("ADODB.Command") 
Conn.Provider = "ADsDSOObject" 
Conn.Open "Active Directory Provider" 
Set Comm.ActiveConnection = Conn 
Comm.Properties("Page Size") = 1000 
  
strBase   =  "<LDAP://" & oRootDSE.get("defaultNamingContext") & ">;" 
strFilter = "(&(objectCategory=person)(objectclass=user)(objectCategory=person)(!wwwhomepage=*));"  
strAttrs  = "givenName,sn;" 
strScope  = "subtree" 
 
Comm.CommandText = strBase & strFilter & strAttrs & strScope 
Set RS = Comm.Execute 

If NOT RS.EOF Then 

Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\noids.txt", true)

	RS.MoveFirst 
	MyFile.WriteLine("First Name,Last Name") 
	Do Until RS.EOF 
        	'WScript.Echo Rs.Fields(0) & "," & RS.Fields(1) 
        	MyFile.WriteLine(Rs.Fields(0) & "," & RS.Fields(1))	
	RS.MoveNext 
	Loop 
 End If
Conn.Close
MyFile.Close

Set oRootDSE = Nothing 
Set Conn = Nothing 
Set Comm = Nothing 
Set User = Nothing 
Set fso = Nothing

Initial URL

                                

Initial Description

                                

Initial Title
LDAP query to find all users without an entry in the webpage field in Active Directory

Initial Tags

                                

Initial Language
Visual Basic