473,657 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

import LDIF file to Access using VB

3 New Member
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 8886
comteck
179 New Member
What is LDIF?

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

Basically its a multiline text file. I need to be able to import the values (ignoring all "objectclas s" 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: organizationalP erson
objectclass: inetOrgPerson
objectclass: mozillaAbPerson Alpha
uid: 1010001
cn: name
sn: surname
mozillaNickname :
description: text data

becomes......

dn............. ..........uid.. ..........cn... ......sn....... ....mozillanick name...descript ion
uid=1010001.... .1010001....nam e....surname... ............... ............tex t 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
Afri473
1 New Member
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 New Member
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_sav e_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(Dat e), 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.OpenRecords et("SELECT * FROM query_export_da ta_ to_thunderbird" , dbOpenSnapshot, dbReadOnly)

' Add contacts

While Not rst.EOF
Print #intFileNum, "dn: uid=" & rst!an_conto & rst!co_ID
Print #intFileNum, "objectclas s: top"
Print #intFileNum, "objectclas s: person"
Print #intFileNum, "objectclas s: organizationalP erson"
Print #intFileNum, "objectclas s: inetOrgPerson"
Print #intFileNum, "objectclas s: mozillaAbPerson Alpha"
Print #intFileNum, "uid: " & rst!co_ID
Print #intFileNum, "cn: " & rst!nome_cognom e
Print #intFileNum, "sn: " & rst!cognome
Print #intFileNum, "mozillaNicknam e: " & rst!nick
Print #intFileNum, "mail: " & rst!Email
Print #intFileNum, "mozillaSecondE mail: " & rst!email2
Print #intFileNum, "telephonenumbe r: " & 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, "mozillaHomeStr eet2: " & rst!casa_ind2; ""
Print #intFileNum, "mozillaHomeLoc alityName: " & rst!casa_città; ""
Print #intFileNum, "mozillaHomeSta te: " & rst!casa_pr; ""
Print #intFileNum, "mozillaHomePos talCode: " & rst!casa_cap; ""
Print #intFileNum, "mozillaHomeCou ntryName: " & rst!casa_naz; ""
Print #intFileNum, "street: " & rst!lav_ind; ""
Print #intFileNum, "mozillaWorkStr eet2: " & 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, "descriptio n: " & 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!fi eldnames 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
2446
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
3645
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
4020
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 user has the ability to upload a file (.txt or .csv). The data in the file may be comma delaminated, tab delaminated, fixed width etc (we don't know). What I'd like to create is something like MS Access uses to import an Excel file into the...
2
3586
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 LDAP objects. I need to be able to read the records from an LDIF file into ..Net. There exists a Perl module that will do exactly this called Net::LDAP::LDIF but I am wanting to port my code over to .Net and cannot find anything with similar...
0
3469
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 of "none" (this is how I read to do it from newsgroups). When I use the Query window in phpmyadmin to import the text file, it waits a while, then returns an error: #1064 - You have an error in your SQL syntax; check the manual that...
1
2429
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) over to distribution lists in Exchange. I have the alias entries in an Access database, in the format 1 - aliasname1 - name1 - name2 - name3 - etc.
10
8248
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 which is - dn: dc=example,dc=com objectClass: top objectClass: dcObject objectClass: organization
9
5771
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
26304
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 one table. My problem is I have two buttons I want to use this code for for the two buttons would put the data in different tables. I have tried copying and changing a few things and nothing will work for me. The code is set up in a module and then I...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.