Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
creds, err := credentials.NewCredentials(authDomain, authUsername, authPassword, authHashes)
if err != nil {
logger.Warn(fmt.Sprintf("Error creating credentials: %s", err))
return
os.Exit(1)
}

// Parsing input values for Distinguished Name
Expand All @@ -89,12 +89,12 @@ func main() {
ldapSession, err := ldap.NewSession(domainController, ldapPort, creds, useLdaps, useKerberos)
if err != nil {
logger.Warn(fmt.Sprintf("Error creating LDAP session: %s", err))
return
os.Exit(1)
}
success, err := ldapSession.Connect()
if err != nil {
logger.Warn(fmt.Sprintf("Error connecting to LDAP: %s", err))
return
os.Exit(1)
}

if success {
Expand All @@ -108,7 +108,7 @@ func main() {
ldapResults, err := ldapSession.QueryWholeSubtree("", query, attributes)
if err != nil {
logger.Warn(fmt.Sprintf("Error querying LDAP: %s", err))
return
os.Exit(1)
}

og := gopengraph.NewOpenGraph("KeyCredentialBase")
Expand All @@ -119,18 +119,19 @@ func main() {
jsonData, err := og.ExportJSON(false)
if err != nil {
logger.Warn(fmt.Sprintf("Error serializing graph to JSON: %s", err))
return
os.Exit(1)
}
err = os.WriteFile(outputFile, []byte(jsonData), 0600)
if err != nil {
logger.Warn(fmt.Sprintf("Error writing graph to file %s: %s", outputFile, err))
return
os.Exit(1)
}
logger.Info(fmt.Sprintf("Graph exported to file: %s", outputFile))

} else {
if debug {
logger.Warn("Error: Could not create ldapSession.")
}
os.Exit(1)
}
}
Loading