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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AD access with VB.NET

Status
Not open for further replies.

andyoye

IS-IT--Management
Mar 23, 2004
56
US
I want to pull user login, home directory... etc from AD using VB.NET
Someone told me to use System.DirectoryServices, but I am new to VB.NET

I can get the result by using dsquery..

dsquery * OU=Users,OU=xxx,OU=xxxx,DC=xxxx,DC=xxxx,DC=xxxx,DC=com -filter "(&(objectCategory=person)(objectClass=user)( !(userAccountControl:1.2.840.113556.1.4.803:=2)))" -attr sAMAccountName distinguishedName homeDirectory -limit 0

Kindly just write a code to extract user home directory

Thanks in advance
 
Code:
 Const ADS_SCOPE_SUBTREE = 2

            objconnection = CreateObject("ADODB.Connection")
            objcommand = CreateObject("ADODB.Command")
            objconnection.Provider = "ADsDSOObject"
            objconnection.Open("Active Directory Provider")
            objcommand.ActiveConnection = objconnection

            objcommand.Properties("Page Size") = 1000
            objcommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
            ListView1.Items.Clear()
            objcommand.CommandText = _
                "SELECT Mail FROM 'LDAP://" & <NAME> & strdnsdomain & "' WHERE objectCategory='User'"
            objrecordset = objcommand.Execute
This is what i use to connect to AD and query its properties.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top