Convert This bit of Vbscript to VB.Net 2005

Author Message
cjwallace

  • Total Posts : 549
  • Scores: 0
  • Reward points : 0
  • Joined: 3/5/2005
  • Location: United Kingdom
  • Status: offline
Convert This bit of Vbscript to VB.Net 2005 Monday, July 16, 2007 9:08 AM (permalink)
0
Hi guys. I really hope someone can help me. As some of you will remember i created a Active Directory User Creation Script and someone was able to help me put the following code together.

Basically is query's AD for Exchange DL's and displays them in a List box.

Well i am now moving onto .vb.net and really need somehelp in moving this bit of code over. Can someone please help me.

Thanks very much in advance



 [font="courier new"][size="2"][/size][/font]Dim strQuery, objConnection, objCommand, objRecordSet, strDomain, strHTML
 
        Dim objRoot
 
 
 
        objRoot = GetObject("LDAP://RootDSE")
 
        strDomain = objRoot.Get("DefaultNamingContext")
 
        strQuery = "<LDAP://" & strDomain & ">;(&(&(|(&(objectCategory=person)(objectSid=*)" & _
 
                   "(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))" & _
 
                   "(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14)))(& (mailnickname=*)" & _
 
                   "(| (objectCategory=group) ))));name,distinguishedname;subtree"
 
        objConnection = CreateObject("ADODB.Connection")
 
        objCommand = CreateObject("ADODB.Command")
 
        objConnection.Open("Provider=ADsDSOObject;")
 
        objCommand.ActiveConnection = objConnection
 
        objCommand.CommandText = strQuery
 
        objCommand.Properties("Sort On") = "Name"
 
        objRecordSet = objCommand.Execute
 
 
 
        strHTML = "<select size='10' id='distributionlists' multiple>"
 
        Do Until objRecordSet.EOF
 
            strHTML = strHTML & "<option value='" & objRecordSet.Fields("distinguishedname") & "'>" & _
 
            objRecordSet.Fields("name") & "</option>"
 
            objRecordSet.MoveNext()
 
        Loop
 
        strHTML = strHTML & "</Select>"
 
 
 
        objConnection.Close()
 
        window.document.getElementById("DisplayDL").innerHTML = strHTML
 

<message edited by cjwallace on Monday, July 16, 2007 9:28 AM>
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • 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
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9