Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 30th, 2004, 12:22 AM   #1
vhinehds
Newbie
 
Join Date: Jun 2004
Posts: 2
Rep Power: 0 vhinehds is on a distinguished road
Hi guys, well i have this big problem. i am working in a company which uses active directory / LDAP. my question now is, i want to make a VB application where it will display the client's e-mail address who is using the application in a textbox. your support is highly needed, thanks in advance guys.
__________________
Prepare your soul for the Reaper.
vhinehds is offline   Reply With Quote
Old Jul 13th, 2004, 11:04 AM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Does this help?

Public Function UserInfo(LoginName As String) As String
'PURPOSE: Display information that is available in
'the Active Directory about a given user

'PARAMETER: Login Name for user

'RETURNS: String with selected information about
'user, or empty string if there is no such
'login on the current domain

'REQUIRES: Windows 2000 ADSI, LDAP Provider
'Proper Security Credentials.

'EXAMPLE: msgbox UserInfo("Administrator")

Dim conn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim oRoot As IADs
Dim oDomain As IADs
Dim sBase As String
Dim sFilter As String
Dim sDomain As String

Dim sAttribs As String
Dim sDepth As String
Dim sQuery As String
Dim sAns As String

Dim user As IADsUser

On Error GoTo ErrHandler:

'Get user Using LDAP/ADO. There is an easier way
'to bind to a user object using the WinNT provider,
'but this way is a better for educational purposes
Set oRoot = GetObject("LDAP://rootDSE")
'work in the default domain
sDomain = oRoot.Get("defaultNamingContext")
Set oDomain = GetObject("LDAP://" & sDomain)
sBase = "<" & oDomain.ADsPath & ">"
'Only get user name requested
sFilter = "(&(objectCategory=person)(objectClass=user)(name=" _
 & LoginName & "))"
sAttribs = "adsPath"
sDepth = "subTree"

sQuery = sBase & ";" & sFilter & ";" & sAttribs & ";" & sDepth
          
conn.Open _
 "Data Source=Active Directory Provider;Provider=ADsDSOObject"
 
Set rs = conn.Execute(sQuery)

If Not rs.EOF Then
  Set user = GetObject(rs("adsPath"))
  With user
  
  'if the attribute is not stored in AD,
  'an error will occur. Therefore, this
  'will return data only from populated attributes
  On Error Resume Next
  
  sAns = "First Name: " & .FirstName & vbCrLf
  sAns = sAns & "Last Name " & .LastName & vbCrLf
  sAns = sAns & "Employee ID: " & .EmployeeID & vbCrLf
  sAns = sAns & "Title: " & .Title & vbCrLf
  sAns = sAns & "Division: " & .Division & vbCrLf
  sAns = sAns & "Department: " & .Department & vbCrLf
  sAns = sAns & "Manager: " & .Manager & vbCrLf

  sAns = sAns & "Phone Number: " & .TelephoneNumber & vbCrLf
  sAns = sAns & "Fax Number: " & .FaxNumber & vbCrLf
  
  sAns = sAns & "Email Address: " & .EmailAddress & vbCrLf
  sAns = sAns & "Web Page: " & .HomePage & vbCrLf
  sAns = sAns & "Last Login: " & .LastLogin & vbCrLf
  sAns = sAns & "Last Logoff: " & .LastLogoff & vbCrLf
  
  sAns = sAns & "Account Expiration Date: " _
     & .AccountExpirationDate & vbCrLf
  
  'IN RC2, this returned 1/1/1970 when password 
  'never expires option is set
  sAns = sAns & "Password Expiration Date: " _
   & .PasswordExpirationDate
    
  End With
End If
UserInfo = sAns
ErrHandler:

On Error Resume Next
If Not rs Is Nothing Then
  If rs.State <> 0 Then rs.Close
  Set rs = Nothing
End If

If Not conn Is Nothing Then
  If conn.State <> 0 Then conn.Close
  Set conn = Nothing
End If

Set oRoot = Nothing
Set oDomain = Nothing
End Function

I havn't tested it, but after googling for a bit i came up with it...i think that what you want....if not, just post and give us more info.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 19th, 2004, 8:37 AM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Did it help?
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 19th, 2004, 1:26 PM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,453
Rep Power: 7 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
I'm in the midst of writing an interface for our old homegrown authentication and account management system to the active directory technology.

I would strongly suggest that you review ADSI (Active Directory Services Interface) in addition to your LDAP approach. I would also advice to bind to the object's GUID and not the canonical name.

ADSI will make the process alot easier... give it a try, post back if you have problems.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:34 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC