Hey everyone, I need more help.
I am creating an IT Trouble Ticket app. All the users are on an Active Directory Domain. I want to pull the existing email address of the logged-in user and prepopulate a text field. I pulled the following example from another site and started modifying it.
Code:Public Function GetEmailAddress(ByVal UserName As String) As String Dim ADObject As Object Dim ADUser As Object Dim DomainDN As String ' Replace with your domain's root DN (e.g., "LDAP://dc=yourdomain,dc=com") DomainDN = "LDAP://" & "form-tec.local" ' Create an Active Directory object Set ADObject = CreateObject("ADSI.Searcher") ' Set the search parameters With ADObject .Root = DomainDN .SearchScope = 2 ' SearchScope.Subtree .Filter = "(sAMAccountName=" & UserName & ")" .PropertiesToLoad = Array("mail") End With ' Perform the search Set ADUser = ADObject.FindOne() ' Check if a user was found If Not ADUser Is Nothing Then GetEmailAddress = ADUser.Properties("mail").Value Else GetEmailAddress = "" ' Or handle the "not found" case as needed End If ' Clean up Set ADUser = Nothing Set ADObject = Nothing End Function
When i get to the " Set ADObject = CreateObject("ADSI.Searcher")", it throws an error 429; "Activex component can't create object"
Researching the error like a good coder, one of the suggestions is to register the DAO 3.6. I do so, and that is successful. But when I go into References, I see that "Microsoft DAO Object Library" is not checked. When I check it and click "OK", I get "Name conflicts with existing module, project, or object library". I have no modules or projects anywhere close to this name, and my
References are:
Visual Basic for Applications
Microsoft Access 16.0 Object Library
OLE Automation
Microsoft Office 16.0 Access database engine Object Library
Microsoft Outlook 16.0 Object Library
Can anyone help?