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

ADSI/LDAP

Status
Not open for further replies.

ZernanToledo

Programmer
Aug 8, 2006
3
0
0
IE
In the intranet system I'm building I need to draw information about Staff and integrate it into Department pages, and also make it accessible via querystrings (so users can search for names). I've asked my IT department how to do this and they basically said "ask the internet"

To summarise I need to :

A) draw names, phone numbers, email addresses to show on relevant department pages. (the code examples pertain to this)

B) Make a facility to search staff names to bring up similar information.

I've had limited success using two different methods, but both have drawbacks. Using ADSI I can get username, description and email info, however cannot seen to find a way to access phone & fax information. The code is:

Code:
	Set Group = GetObject("WinNT://" & sDomainName & "/" & sGroupName)
			
	For Each Member in Group.Members

	    If Member.Class = "User" Then
			
		oFullName = Member.FullName
		[COLOR=red]oPhone = ????[/color]
                oMailStart = Member.Name
			 
		IF oFullName = "" THEN 
			oFullName = "<div class=""Capital"">" & Replace(oMailStart, ".", " ") & "</div>"
		ELSE 
			 oFullName = oFullName
		END IF 
			 
		 IF oPhone = "" THEN 
			 oPhone = "N/A"
		ELSE 
			oPhone = oPhone
		END IF 

		IF oMailStart = "" THEN 
			 oMailStart = "<td>N/A</td>"
		 ELSE 
			 oMailStart = "<td><a href=""mailto:" & oMailStart & "@mydomain.com"">" & oMailStart & "@mydomain.com</td>"
		END IF 
			 	
			
	    End If

I know you can access this info using LDAP, however my experiments with this have been less sucessful. I can access the info, but have no idea how to filter it via Group (i.e. department).

Code:
Set oRootDSE 		= GetObject("LDAP://RootDSE")
sDomainADsPath		= "LDAP://" & oRootDSE.Get("defaultNamingContext")
Set oRootDSE 		= Nothing

SQLStmt = "SELECT cn " & _
          "FROM '" & sDomainADsPath & "' " & _
          "WHERE objectClass='*'"

Set oCon = Server.CreateObject("ADODB.Connection")
oCon.Provider = "ADsDSOObject"
oCon.Open "ADProvider"

Set rs = oCon.Execute(SQLStmt)

Do While Not rs.EOF Or rs.BOF
   ReturnValue = rs.Fields(0)
   If IsArray(ReturnValue) Then
        For I = LBound(ReturnValue) To UBound(ReturnValue)
            If ReturnValue(I) <> "" Then
                Response.Write ReturnValue(I) & "<BR>"
            End If
        Next
   Else
        Response.Write ReturnValue & "<BR>"
   End If
   rs.MoveNext
Loop

I've scoured google and many forums trying to find a solution using either method, but with no luck. Info is usually to obtuse or over my head to make sense. I think you guys may be my last hope.

Any help is much appreciated!
 
Check out the links in this thread: thread333-1263762

If they don't help, I may beable to scrape somethng up that is more helpful once I get to work and have access to my laptop thatI lazily left there yesterday.

 
Active Directory is very good at storing all kinds of information and for performing enterprise wide administration. However for an intranet it could be argued that it is better to build your own custom database (eg MS SQL or Access) and report off that. You could put whoever is in charge of HR in charge of the database and only they can see all of it then have a page on the intranet which is a telephone listing that feeds directly off that but only shows limited information.
 
Hi

I discussed storing user info in the SQL database, but my IT department are feircely against this, as they say they do not want replication of information. They told me to go find out about these subjects instead, so I'm stuck with having to find a solution!
 
Here's another user trying to do something similar:
thread955-1253717

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top