Solved

How do I create a view to see active directory information in sql server 2000 ?

Posted on 2008-10-20
1
183 Views
Last Modified: 2009-04-14
I need create a view that will return active directory information as a view; specifically ; I need the login name and full name of the user. I have successfully done this once in ASP; but need to have it as a view on SQL server for another application; I have already linked the ADSI server but all attempts at creating a view like this apparently run up against the brick wall of logging in as  my low security user.
Attached is how i did it in ASP:

strUser = "SCAP\phonebook"
strPassword = "phonebook"
 
    ' Dim Conn, strRS, RS, strConn 
     Set Conn = Server.CreateObject("ADODB.Connection") 
     Set RS = Server.CreateObject("ADODB.Recordset") 
     Conn.Provider = "ADsDSOObject" 
     Conn.Properties("User ID") = strUser
     Conn.Properties("Password") = strPassword
     Conn.Properties("Encrypt Password") = True
     strConn = "Active Directory Provider" 
     Conn.Open strConn , strUser, strPassword
 
     strRS = "SELECT displayname,sn,givenname,telephoneNumber,objectCategory,department  FROM 'LDAP://SCAP' WHERE "
     
     strRS =  strRS & "objectCategory = 'CN=Person,CN=Schema,CN=Configuration,DC=assessor,DC=shelby,DC=tn,DC=us'"
     strRS =  strRS & " and ( telephoneNumber = '5*' "
     strRS =  strRS & " or telephoneNumber = '3*' ) order by sn"
     RS.Open strRS, Conn

Open in new window

0
Comment
Question by:shelbyinfotech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
MohammedU earned 500 total points
ID: 22761608
Here it is...
http://codebetter.com/blogs/brendan.tompkins/archive/2003/12/19/4746.aspx
Step 1: Create a linked server to your Active Directory

sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADSDSOObject', 'adsdatasource'

Step 2: Create a view in SQL server using OPENQUERY to select from Active Directory

CREATE  VIEW dbo.vw_AD_USER_INFO
AS

SELECT * FROM OpenQuery(ADSI, 'SELECT title, displayName, sAMAccountName, givenName, telephoneNumber, facsimileTelephoneNumber, sn FROM ''LDAP://DC=whaever,DC=domain,DC=org'' where objectClass = ''User''')

GO
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can we attach PDF to table 2 46
Using rowversion for incremental load of datawarehouse. 12 35
Access PS SQLSERVER from powershell 1 29
Query Task 8 14
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question