473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

import LDIF file to Access using VB

3
Hi everyone

I've created a database of contacts from which I'd like to export/import in LDIF format - which would obviously permit me to import to Thunderbird :D .

I've managed to export to the LDIF format following some code I found on the net (thanks ) but I haven't been able to do the opposite, i.e. import into access from the LDIF format.

I've found lots of hints regarding the use of INPUT, EOF, InStr etc., but I haven't really been able to get my head round it. I'm not a programmer, obviously, just a frustrated "wish I was one".

Would anyone be able to provide example code that I can then try to adapt?

Thanks for any help you guys can give me

JADE
Jul 18 '06 #1
4 8845
comteck
179 100+
What is LDIF?

comteck
Jul 19 '06 #2
jade
3
See this link
what is LDIF

Basically its a multiline text file. I need to be able to import the values (ignoring all "objectclass" lines) into a table, where the attribute name is the same as the column name in the table.

e.g.
dn: uid=1010001
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
objectclass: mozillaAbPersonAlpha
uid: 1010001
cn: name
sn: surname
mozillaNickname:
description: text data

becomes......

dn.......................uid............cn........ .sn...........mozillanickname...description
uid=1010001.....1010001....name....surname........ ......................text data


where the first line =column names, and the second line contains the data.

Each record is divided by an empty line (or carriage return & line feed).
Each record starts with the "dn" attribute
Not all attributes will have a value
Not necessarily all attributes will be listed for each record.
Jul 19 '06 #3
Hi everyone

I've created a database of contacts from which I'd like to export/import in LDIF format - which would obviously permit me to import to Thunderbird :D .

I've managed to export to the LDIF format following some code I found on the net (thanks ) but I haven't been able to do the opposite, i.e. import into access from the LDIF format.

I've found lots of hints regarding the use of INPUT, EOF, InStr etc., but I haven't really been able to get my head round it. I'm not a programmer, obviously, just a frustrated "wish I was one".

Would anyone be able to provide example code that I can then try to adapt?

Thanks for any help you guys can give me

JADE
Hi !
I´m sorry, I can´t help You, but I´m interested in Your export solution.
I am looking for a tool to make an LDIF File from an Access database, but as yet I did not find one.
Oct 15 '06 #4
jade
3
1. Basically you need to create a query which pulls together the contact data you want to put in the LDIF file.
2. The names of these fields must then be "matched" to the names in Thunderbird ... and the match written into a module function.
3. Launch the function using a button
.................................................. ......................
Following is the function I use - save it into a new module
.................................................. ......................

Function BuildLDIF() As Boolean

Const csPathName = "C:\path_to_save_LDIF_file\"

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rstMembers As DAO.Recordset
Dim intFileNum As Integer
Dim strFileName As String * 19
Dim csCRLF As String * 2

Set dbs = currentdb
csCRLF = Chr(13) + Chr(10)

' This command assigns the next available file number to the variable intFileNum.
' I believe this technique is better than trying to keep track of actual numbers.
intFileNum = FreeFile

' This next line creates the name of the text file, based on the current date.
' The filename will be of the form "DB-YYMMDD.ldif
' strFileName = "DB" & Right$(Year(Date), 2) & String$(2 - Len(Month(Date)), "0") & Month(Date) & String$(2 - Len(Day(Date)), "0") & Day(Date) & ".ldif"
strFileName = "DB-YYMMDD.ldif"
' This command opens the file, and includes several optional parameters:
' For Output = mode to open the file. Output specifies write-only,sequential access.
' it will also overwrite an existing file with the same name, if it exists.
' Access Write = Optional; specifies write-only access to the file.
' Lock Read Write = Optional; locks the file from being read or written to while
' in use.
Open csPathName & strFileName For Output Access Write Lock Read Write As intFileNum

Set rst = dbs.OpenRecordset("SELECT * FROM query_export_data_ to_thunderbird", dbOpenSnapshot, dbReadOnly)

' Add contacts

While Not rst.EOF
Print #intFileNum, "dn: uid=" & rst!an_conto & rst!co_ID
Print #intFileNum, "objectclass: top"
Print #intFileNum, "objectclass: person"
Print #intFileNum, "objectclass: organizationalPerson"
Print #intFileNum, "objectclass: inetOrgPerson"
Print #intFileNum, "objectclass: mozillaAbPersonAlpha"
Print #intFileNum, "uid: " & rst!co_ID
Print #intFileNum, "cn: " & rst!nome_cognome
Print #intFileNum, "sn: " & rst!cognome
Print #intFileNum, "mozillaNickname: " & rst!nick
Print #intFileNum, "mail: " & rst!Email
Print #intFileNum, "mozillaSecondEmail: " & rst!email2
Print #intFileNum, "telephonenumber: " & rst!tel_lav
Print #intFileNum, "homePhone: " & rst!tel_casa
Print #intFileNum, "fax: " & rst!fax
Print #intFileNum, "pager: " & rst!cercap
Print #intFileNum, "mobile:" & rst!Cell; ""
Print #intFileNum, "homeStreet: " & rst!casa_ind; ""
Print #intFileNum, "mozillaHomeStreet2: " & rst!casa_ind2; ""
Print #intFileNum, "mozillaHomeLocalityName: " & rst!casa_città; ""
Print #intFileNum, "mozillaHomeState: " & rst!casa_pr; ""
Print #intFileNum, "mozillaHomePostalCode: " & rst!casa_cap; ""
Print #intFileNum, "mozillaHomeCountryName: " & rst!casa_naz; ""
Print #intFileNum, "street: " & rst!lav_ind; ""
Print #intFileNum, "mozillaWorkStreet2: " & rst!lav_ind2; ""
'Print #intFileNum, "l: " & rst!; ""
Print #intFileNum, "st: " & rst!lav_pr; ""
Print #intFileNum, "postalCode: " & rst!lav_cap; ""
Print #intFileNum, "c: " & rst!lav_nazione; ""
Print #intFileNum, "title: " & rst!lav_titolo; ""
Print #intFileNum, "department: " & rst!reparto; ""
Print #intFileNum, "company: " & rst!azienda; ""
Print #intFileNum, "mozillaWorkUrl: " & rst!lav_web; ""
Print #intFileNum, "mozillaHomeUrl: " & rst!casa_web; ""
Print #intFileNum, "mozillaCustom1: " & rst!p1; ""
Print #intFileNum, "mozillaCustom2: " & rst!p2; ""
Print #intFileNum, "mozillaCustom3: " & rst!p3; ""
Print #intFileNum, "mozillaCustom4: " & rst!p4; ""
Print #intFileNum, "description: " & rst!note & csCRLF
rst.MoveNext
Wend

rst.Close
Set rst = Nothing
Set dbs = Nothing
Close ' Closes the output to the text file.

BuildLDIF = True

End Function
.................................................. ..........................................
Obviously, don't forget to replace my path, filename,rst!fieldnames with yours etc.
NOTE THAT THE FUNCTION IS NOT MINE, I FOUND IT ON THE WEB.....THANKS ONCE AGAIN TO ITS AUTHOR
Then create a button in a mask that calls the function BuildLDIF.

Good luck
Nov 6 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Loren | last post by:
I Have an August 1st deadline to convert an XML file to an LDIF/LDAP File. Some one told me that i should use java. Can anyone help Please?! I have never programed in java before.
0
by: Loren | last post by:
I Have an August 1st deadline to convert an XML file to an LDIF/LDAP File. Some one told me that i should use perl. Can anyone help Please?! I have never programed in perl before.
1
by: David Berry | last post by:
Hi All. I'm looking for any help or sample code that can show me how to make a file import wizard in ASP.NET (VB preferred) like the one that MS Access uses. I'm working on a web site where the...
2
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
0
by: NewbieSupreme | last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x, which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a table to a text file, tab-delimited, text qualifyer...
1
by: Maurice | last post by:
Hello all, I think Access is the tool I need for this but I'm having a little trouble figuring out the best way to accomplish. We are converting a lot of aliases (from a sendmail alias file)...
10
by: Cruelemort | last post by:
All, I am hoping someone would be able to help me with a problem. I have an LDAP server running on a linux box, this LDAP server contains a telephone list in various groupings, the ldif file of...
9
by: a | last post by:
Dear friends I want import data from CSV file to mdb file How can I do that in vb.net?
6
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.