TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
michael williams
NA
3
0
AD sync from SQL server
Mar 26 2010 10:26 AM
Hello. I'm currently working on an app that will submit a query to a sql database containing user names and school names. I will then take this information and use it to build one of our AD sub domains. Once it has added the users, I will plan to have the app run every few days to verify everything is still synched, and change user attributes in AD if needed.
I have the first part working - I'm successfully able to query the sql db and pull in everything I want into a data table. I'd like to do something similar with AD if possible, which would be to pull users' user names, first and last names, department (for storing unique identifier from sql db), and the OU they're in into a data table.
I feel that once I get them both in a data table, I'll be able to search through them for a unique identifier and verify that everything matches. I found a couple resources, but I haven't been able to make this work. Below is some code I found that pulls in whatever the objectcategory is set to, but I haven't been able to figure out how to make it pull all the values i want into a data table. A multidimensional array would probably work fine as well I would think.
Any help would be appreciated.
Try
Dim
enTry
As
System.DirectoryServices.DirectoryEntry =
New
System.DirectoryServices.DirectoryEntry(
"LDAP://DC=student,DC=domain,DC=local"
)
Dim
mySearcher
As
System.DirectoryServices.DirectorySearcher =
New
System.DirectoryServices.DirectorySearcher(enTry)
mySearcher.Filter = (
"(objectCategory=computer)"
)
Dim
resEnt
As
System.DirectoryServices.SearchResult
For
Each
resEnt
In
mySearcher.FindAll()
Try
Console.WriteLine(
":Processing:"
& Mid(resEnt.GetDirectoryEntry().Name.ToString(), 4))
Catch
ex
As
Exception
Console.WriteLine(
"Trying to Connect to: "
& _
resEnt.GetDirectoryEntry().Name.ToString() & vbCrLf & ex.Message.ToString())
End
Try
Next
Catch
End
Try
Reply
Answers (
0
)
LDAP queries to Active Directory from another computer within same domain.
Self Service Password Reset for Microsoft Active Directory