-1
dn: CN=FirstName LastName,OU=IT Group,OU=Resources,OU=CompanySite,DC=example,DC=com
changetype: add
accountExpires: 0
businessCategory: iDQC
c: US
cn: FirstName LastName
co: United States
codePage: 0
company: CompanySite
countryCode: 840
department: Information Technology
description: 2/24/2015 10:39:25 AM firstname.lastname logged on to COMPUTERNAME
displayName: FirstName LastName
distinguishedName: 
 CN=FirstName LastName,OU=IT Group,OU=CompanySite,DC=example,DC=com
division: N/A
dSCorePropagationData: 20160511184301.0Z
dSCorePropagationData: 20160222194509.0Z
dSCorePropagationData: 20150710200320.0Z
dSCorePropagationData: 20140926143022.0Z
dSCorePropagationData: 16010714223649.0Z
.... (hundreds of lines here)

I have a LDF file that looks like this.

I want to retrieve the following fields

department
telephoneNumber
title

Is there a better way to do this than read each row by row?

software is fun
  • 7,286
  • 18
  • 71
  • 129

1 Answers1

1
var foundLines = File.ReadLines(<ldif file>)
  .Where(l=>l.StartsWith("department") || l.StartsWith("title") || l.StartsWith("telephoneNumber"));

is a good start, but its not magic, its just reading all the lines of the file.

pm100
  • 48,078
  • 23
  • 82
  • 145