.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 19th, 2005, 10:38 AM
MikeBarbu MikeBarbu is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 MikeBarbu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Pulling Active Directory info into an array

The following code SHOULD work, but it isn't pulling data. Is there a NEWER/BETTER way to pull data from Active Directory?
PLEASE HELP, here is the code:

Dim RecordSet AsNew ADODB.Recordset
Dim Command AsNew ADODB.Command
Dim arrayUserADInfo AsNew doUserInfo
Dim Connection AsNew ADODB.Connection

Try
With Connection
.Provider = "ADsDSOObject"
.Open("Active Directory Provider")
.Properties("User ID").Value = "ADUserID"
.Properties("Password").Value = "ADPassword"
.Properties("Encrypt Password").Value = True
End With

Dim SelectStatement As String = "department, departmentNumber, description, displayName, employeeID, facsimileTelephoneNumber, givenName, lastLogoff, lastLogon, mail, manager, middleName, mobile, pager, photo, SAMAccountName, SN, telephoneNumber, title"
Dim FromStatement As String = LDAP://DC=stph,DC=org
Dim WhereStatement As String = "objectCategory='Person' AND SAMAccountName='" & strUserName & "'"

Command.ActiveConnection = Connection
Command.CommandText = "SELECT " & SelectStatement & " FROM " & FromStatement & " WHERE " & WhereStatement
RecordSet = Command.Execute
If Not RecordSet.EOF Then
'arrayEmployeeInfo.ADsPath = RecordSet.Fields("ADsPath").Value
arrayUserADInfo.department = RecordSet.Fields("department").Value
arrayUserADInfo.departmentNumber = RecordSet.Fields("departmentNumber").Value
arrayUserADInfo.description = RecordSet.Fields("description").Value
arrayUserADInfo.displayName = RecordSet.Fields("displayName").Value
arrayUserADInfo.employeeID = RecordSet.Fields("employeeID").Value
arrayUserADInfo.facsimileTelephoneNumber = RecordSet.Fields("facsimileTelephoneNumber").Value
arrayUserADInfo.givenName = RecordSet.Fields("givenName").Value
arrayUserADInfo.lastLogoff = RecordSet.Fields("lastLogoff").Value
arrayUserADInfo.lastLogon = RecordSet.Fields("lastLogon").Value
arrayUserADInfo.mail = RecordSet.Fields("mail").Value
arrayUserADInfo.manager = RecordSet.Fields("manager").Value
arrayUserADInfo.middleName = RecordSet.Fields("middleName").Value
arrayUserADInfo.mobile = RecordSet.Fields("mobile").Value
arrayUserADInfo.pager = RecordSet.Fields("pager").Value
arrayUserADInfo.photo = RecordSet.Fields("photo").Value
arrayUserADInfo.SAMAccountName = RecordSet.Fields("SAMAccountName").Value
arrayUserADInfo.SN = RecordSet.Fields("SN").Value
arrayUserADInfo.telephoneNumber = RecordSet.Fields("telephoneNumber").Value
arrayUserADInfo.title = RecordSet.Fields("title").Value
End If
Return arrayUserADInfo
Catch ex As Exception
'Insert Error Handling Here
Finally
'RecordSet.Close()
'Connection.Close()
End Try

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Pulling Active Directory info into an array


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT