Hi,
I am wanting to make a db that pulls user clients info from the network in Active Directory. Has anyone been able to search through Access and connect to Active Directory? Was wanting to do an number of things, like search by User ID, and pull address, phone and computer info, then remotely connect to PC etc.
Thanks,
I have some code that may help : - 'GetUserObject() returns an IADs object representing either the LDAP: string
-
' if passed, or the logged-on user otherwise.
-
Public Function GetUserObject(Optional ByVal strDN As String = "") As Object
-
If strDN > "" Then
-
Set GetUserObject = GetObject("LDAP://" & strDN)
-
Else
-
strDN = "LDAP://OU=MyBusiness," & _
-
GetObject("LDAP://RootDSE").Get("rootDomainNamingContext")
-
Set GetUserObject = ProcessIAD(GetObject(strDN), GetLogonName)
-
End If
-
End Function
-
-
'ProcessIAD() is called recursively and returns an object only when it is a user
-
' that matches strUser.
-
Private Function ProcessIAD(ByRef iadVar As Object, strUser As String) As Object
-
Dim iadWork As Object
-
-
With iadVar
-
Select Case IADType(iadVar)
-
Case "User"
-
If .sAMAccountName = strUser Then Set ProcessIAD = iadVar
-
Exit Function
-
Case "organizationalUnit"
-
For Each iadWork In iadVar
-
Set ProcessIAD = ProcessIAD(iadWork, strUser)
-
If Not ProcessIAD Is Nothing Then Exit Function
-
Next iadWork
-
End Select
-
End With
-
End Function
-
-
'IADType() returns whether the IAD should be treated as a container
-
' (organizationalUnit), a user (user), or simply ignored (group).
-
Private Function IADType(iadVar As Object) As String
-
Dim varWork As Variant
-
-
With iadVar
-
Call .GetInfo
-
For Each varWork In .Get("objectClass")
-
Select Case varWork
-
Case "user", "group", "organizationalUnit"
-
IADType = varWork
-
Exit For
-
End Select
-
Next varWork
-
End With
-
End Function
The following procedure lists what it finds : - 'ShowIADs() shows all users, groups and containers of the AD from strRoot.
-
Public Sub ShowIADs(Optional ByRef iadVar As Object, _
-
Optional ByVal strRoot As String = "")
-
Dim iadWork As Object
-
Dim strWork As String
-
-
If iadVar Is Nothing Then
-
strWork = "LDAP://" & _
-
strRoot & _
-
"OU=MyBusiness," & _
-
GetObject("LDAP://RootDSE").Get("rootDomainNamingContext")
-
Set iadVar = GetObject(strWork)
-
End If
-
With iadVar
-
strWork = IADType(iadVar)
-
If strWork > "" Then
-
Debug.Print strWork & "," & _
-
IIf(strWork = "user", .sAMAccountName, "") & "#" & _
-
.distinguishedName & "~";
-
End If
-
Select Case strWork
-
Case "user"
-
Exit Sub
-
Case "organizationalUnit"
-
For Each iadWork In iadVar
-
Call ShowIADs(iadWork)
-
Next iadWork
-
End Select
-
End With
-
End Sub
I don't think there are any calls in here except to standard procedures. I think most of this is found in the VBA library.
5 8430
I use an LDAP query when I need to pull data from AD.
NeoPa 32,556
Expert Mod 16PB
I have some code that may help : - 'GetUserObject() returns an IADs object representing either the LDAP: string
-
' if passed, or the logged-on user otherwise.
-
Public Function GetUserObject(Optional ByVal strDN As String = "") As Object
-
If strDN > "" Then
-
Set GetUserObject = GetObject("LDAP://" & strDN)
-
Else
-
strDN = "LDAP://OU=MyBusiness," & _
-
GetObject("LDAP://RootDSE").Get("rootDomainNamingContext")
-
Set GetUserObject = ProcessIAD(GetObject(strDN), GetLogonName)
-
End If
-
End Function
-
-
'ProcessIAD() is called recursively and returns an object only when it is a user
-
' that matches strUser.
-
Private Function ProcessIAD(ByRef iadVar As Object, strUser As String) As Object
-
Dim iadWork As Object
-
-
With iadVar
-
Select Case IADType(iadVar)
-
Case "User"
-
If .sAMAccountName = strUser Then Set ProcessIAD = iadVar
-
Exit Function
-
Case "organizationalUnit"
-
For Each iadWork In iadVar
-
Set ProcessIAD = ProcessIAD(iadWork, strUser)
-
If Not ProcessIAD Is Nothing Then Exit Function
-
Next iadWork
-
End Select
-
End With
-
End Function
-
-
'IADType() returns whether the IAD should be treated as a container
-
' (organizationalUnit), a user (user), or simply ignored (group).
-
Private Function IADType(iadVar As Object) As String
-
Dim varWork As Variant
-
-
With iadVar
-
Call .GetInfo
-
For Each varWork In .Get("objectClass")
-
Select Case varWork
-
Case "user", "group", "organizationalUnit"
-
IADType = varWork
-
Exit For
-
End Select
-
Next varWork
-
End With
-
End Function
The following procedure lists what it finds : - 'ShowIADs() shows all users, groups and containers of the AD from strRoot.
-
Public Sub ShowIADs(Optional ByRef iadVar As Object, _
-
Optional ByVal strRoot As String = "")
-
Dim iadWork As Object
-
Dim strWork As String
-
-
If iadVar Is Nothing Then
-
strWork = "LDAP://" & _
-
strRoot & _
-
"OU=MyBusiness," & _
-
GetObject("LDAP://RootDSE").Get("rootDomainNamingContext")
-
Set iadVar = GetObject(strWork)
-
End If
-
With iadVar
-
strWork = IADType(iadVar)
-
If strWork > "" Then
-
Debug.Print strWork & "," & _
-
IIf(strWork = "user", .sAMAccountName, "") & "#" & _
-
.distinguishedName & "~";
-
End If
-
Select Case strWork
-
Case "user"
-
Exit Sub
-
Case "organizationalUnit"
-
For Each iadWork In iadVar
-
Call ShowIADs(iadWork)
-
Next iadWork
-
End Select
-
End With
-
End Sub
I don't think there are any calls in here except to standard procedures. I think most of this is found in the VBA library.
I have attached a Sample Database that should clearly demonstrate how to retrieve Information from Active Directory. It also display AD Variables that can be used in this same context.
NeoPa 32,556
Expert Mod 16PB
No worries. I'm happy to share it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Victor Lokhmatov |
last post by:
Hello Everyone,
My company has asked me to put a company directory on our intranet site
and I'm trying to use php to extract the users from our active
directory server. I've got everything...
|
by: Henning Kristensen |
last post by:
Hi
I need a little help with some VB.Net code..
I am pulling my computer's GUID out using WMI
Dim wmiObj As New System.Management.ManagementObjectSearcher("SELECT UUID FROM...
|
by: Henning Kristensen |
last post by:
Hi
I need a little help with some VB.Net code..
I am pulling my computer's GUID out using WMI
Dim wmiObj As New System.Management.ManagementObjectSearcher("SELECT UUID FROM...
|
by: Ross Luker |
last post by:
Hi,
I've just started using ADSI to pull in info from our Active Directory
tree into SQL Server 2000. I've made the link ok, and can pull in most
fields (cn whenCreated etc) fine. However,...
|
by: Franklin Zabala |
last post by:
Hello
By any chance, anyone know how to delegate control of an object in active directory programmatically? particularly using C#... I've been pulling my hair for 4 days now and can't still find...
|
by: Andrew |
last post by:
Hey all,
Working on revamping our Intranet here and making use of the LDPA, Active
Directory, Directory Services, etc. that .Net provides. I am still fairly
new on this subject, so the problem...
|
by: tangus via DotNetMonster.com |
last post by:
Hello all, I'm really struggling with getting some Active Directory code to
work in ASP.NET. Can you please provide assistance? I am executing the
following code:
Dim enTry As DirectoryEntry =...
|
by: varkey.mathew |
last post by:
Dear all,
Bear with me, a poor newbie(atleast in AD)..
I have to authenticate a user ID and password for a user as a valid
Active Directory user or not. I have created the IsAuthenticated...
|
by: Hriday |
last post by:
Hi there, Please help me..It is urgent
This is Hriday, working on windows authentication with
Active Directory...
My requirment is when a user sends a request to my web
Applicatoin I want to...
|
by: Joe Spears |
last post by:
Hi
Does anyone have any sample code on Pulling user data from Active
Directory??
Thanks
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |