troubleshooting Question

How to split variable width data

Avatar of Jim P.
Jim P.Flag for United States of America asked on
Microsoft AccessMicrosoft SQL ServerActive Directory
11 Comments1 Solution1048 ViewsLast Modified:
I work with many individual domains (not in a forest) that I need to get a list of all users and dump it to text files.

The dsget statement I'm using is:
dsquery user -limit 0 | dsget user -dn -samid -ln -fn -display -mustchpwd -canchpwd -pwdneverexpires -disabled -acctexpires  > \\192.168.1.2\LogonData\%COMPUTERNAME%_logonnames.txt

The statement works fairly well. It gives me the info I need. Now I am trying to pull the info into an Access DB and I'm finding out the columns are variable width as seen by the header lines below:
  dn                                                      samid                 fn          ln                display                                                 mustchpwd    canchpwd    pwdneverexpires    acctexpires    disabled  
  dn                                                                    samid                 fn           ln                display                                                 mustchpwd    canchpwd    pwdneverexpires    acctexpires    disabled  
  dn                                                                    samid               fn          ln                display                                                 mustchpwd    canchpwd    pwdneverexpires    acctexpires    disabled  
  dn                                                                        samid             fn                ln                  display                     mustchpwd    canchpwd    pwdneverexpires    acctexpires    disabled  

I want to automate the import into Access with VBA; but I am getting beat up on the variable column widths. I could probably get away with using the some sort of Excel
VBA functionality. Or for that matter does anyone know how to query Active Directory straight in to Access or SQL Server?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros