Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting VBA to VBS 2

Status
Not open for further replies.

ClulessChris

IS-IT--Management
Jan 27, 2003
890
GB
Hi,
I'm trying to convert a VBA Routine to VBS. So far I have:
Code:
Dim Conn                       	    
Dim Rs                         	
Dim propList                  	    
Dim propEntry                	
Dim propVal                  	    
Dim V                        	
Dim sQuery, sRtn              
Dim sBase, sFilter            	
Dim sResult
 
    sBase = "<LDAP://x500.inrev.gov.uk/o=inland revenue,c=gb>"
    sFilter = "(&(objectClass=person)(CN=6021134))"
    sQuery = sBase & ";" & sFilter & ";ADsPath;SubTree"

    Conn = CreateObject("ADODB.Connection")
    Conn.Open "Data Source=Active Directory Provider;Provider=ADsDSOObject"

    Set Rs = Conn.Execute(sQuery)

    If Rs.EOF = False Then
        Set propList = GetObject(Rs("ADsPath"))
        propList.GetInfo
      
        Set propEntry = propList.GetPropertyItem("irhomeorganizationalunit", ADSTYPE_CASE_IGNORE_STRING)
        For Each V In propEntry.Values
            Set propVal = V
            Select Case propVal.ADsType
                Case ADSTYPE_CASE_EXACT_STRING
                    sRtn = propVal.CaseExactString
                Case ADSTYPE_CASE_IGNORE_STRING
                    sRtn = propVal.CaseIgnoreString
                Case Else
                    sRtn = "Unable to handle a property of type: " & propVal.ADsType
            End Select
            
        Next
    
    End If
      
    If Left(sRtn, 6) = "Unable" Then
        sResult = sRtn
       
    Else
        sResult = Mid(sRtn, 4, InStr(sRtn, ",") - 4)
      
    End If

   msgbox sResult
    
Tidy_up:
    If Not Rs Is Nothing Then Rs.Close
    If Not Conn Is Nothing Then Conn.Close
    Set Rs = Nothing
    Set Conn = Nothing

So far i'm geting the error Object Required: "

on the line:
Code:
Conn.Open "Data Source=Active Directory Provider;Provider=ADsDSOObject"

I don't see why I'm geting this error.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
[!]Set [/!]Conn = CreateObject("ADODB.Connection")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Many thanks, Don't I feel silly now :)

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Sorry I'm backl again.
I now get the error:
The Active Directory datatype cannot be converted to/from a native datatype

on the line:
Code:
Set propEntry = propList.GetPropertyItem("irhomeorganizationalunit", ADSTYPE_CASE_IGNORE_STRING)

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
tsuji,

many thanks another fine answer.

Regards
Chris

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Also don't forget to take out label: it is neither needed nor supported.
>Tidy_up:
[tt][red]'[/red]Tidy_up:[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top