Creative Commons License
Drekendrop | Blog of Tutorial by Mei Pakpahan is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at drekendrop.blogspot.com.
Permissions beyond the scope of this license may be available at http://softdadesign.co.nr.

Share This

Friday, March 11, 2011

SQL Query: Adding Active Directory Users Attributes To An Existing Table Or Specified Column

OK, here it is, i was trying to create a timetable SharePoint webpart for our school, and using SQL Server Database. And i want the timetable appears as the domain user logged on to SharePoint. So my first step to create this webpart was creating the database and tables. From the previous topic i have explained how to get the Active directory users and attributes, and so i improved the sql query to copy all my AD retrieval results into my 'teacher' table.
Below is the query that i ran:

use TimeTable
go
INSERT INTO teacher(initials,logOnID,preferredName)
SELECT initials,samAccountName, displayName FROM OPENQUERY(ADSI,'SELECT initials, samAccountName, displayName, mail FROM ''LDAP://OU=Teaching Faculty,OU=Staff,DC=BISDRAGONS,DC=COM'' WHERE objectClass=''Person'' AND objectClass = ''User'' ORDER BY samAccountName') where mail IS NOT NULL


And it worked very well for me. :)

5 comments:

Sudheer Gupta said...

hi!

Can u give some more information like schema of teachers table, etc...?

Mei Pakpahan said...

Hi Sudheer, i've posted on the previous post:
Check this out: http://drekendrop.blogspot.com/2011/03/sql-query-retrieve-active-directory.html
And down there, you may find LINK for a complete Active Directory attributes in a table.

Santiago Maldonado said...

Hi, I know is a long time since this post was posted, but I wanna say thanks, you save my ass. Greetings

Mei Pakpahan said...

Hi Santiago! That sounds great, i'm happy that it helps.

daniell marco said...

exactly the part i was missing to complete my project.
cool, thanks
active directory query

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Grants For Single Moms