[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Omit DN information from csvde results

Posted on 2006-06-06
6
Medium Priority
?
3,203 Views
Last Modified: 2008-01-09
I'm trying to create a csv to import users into a database. I'm using the command below and everything works other than i cannot seem to omit the dn in the results file. Any clues?

csvde -f results.csv -d "ou=users,dc=domain,dc=com" -r (&(obbjectClass=user)(objectcategory=person))" -l "cn,sn,givenName,name,sAMAccountName,userPrincipalName,initials" -o "DN"
0
Comment
Question by:josgan
  • 3
  • 3
6 Comments
 

Author Comment

by:josgan
ID: 16846953
need this answer so i'm increasing the points.
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 16850328

DN can't be excluded, it's the unique identifier for the object. You can't delete it afterwards?

Chris
0
 

Author Comment

by:josgan
ID: 16853804
I want to do a straight import into SQL, and the DN information is messing that whole process up. I'm creating a searchable database users can use to check to see if their account exists.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 71

Accepted Solution

by:
Chris Dent earned 800 total points
ID: 16854154

Well all is not lost. It's quite easy to dump that kind of information out with VbScript. There's an example below... you might want to play with the order of the output a little perhaps...

objRootDSE.Get("defaultNamingContext") gets your domain name, so effectively replaces the dc=domain,dc=com if your CSVDE command above.


On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.OpenTextFile("results.csv", 2, True, 0)

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

Set objRootDSE = GetObject("LDAP://RootDSE")
objCommand.CommandText = "SELECT aDSPath, cn, sn, givenName, name, sAMAccountName, userPrincipalName, initials " &_
      "FROM 'LDAP://OU=Users," & objRootDSE.Get("defaultNamingContext") & "'"
Set objRootDSE = Nothing

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 600
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False

Set objRecordSet = objCommand.Execute
While Not objRecordSet.EOF
      Set objEntry = GetObject(objRecordSet.Fields("aDSPath"))
      strClass = "" : strClass = objEntry.Class

      If strClass = "user" Then
            strCN = "" : strSN = "" : strGivenName = "" : strName = "" : strSAMAccountName = ""
            strUPN = "" : strInitials = ""

            strCN = objRecordSet.Fields("cn")
            strSN = objRecordSet.Fields("sN")
            strGivenName = objRecordSet.Fields("givenName")
            strName = objRecordSet.Fields("name")
            strSAMAccountName = objRecordSet.Fields("sAMAccountName")
            strUPN = objRecordSet.Fields("userPrincipalName")
            strInitials = objRecordSet.Fields("initials")

            objFile.WriteLine strCN & "," & strSN & "," & strGivenName & "," & strName & "," &_
                  strSAMAccountName & "," & strUPN & "," & strInitials
      End If
      objRecordSet.MoveNext
Wend

objConnection.Close

Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing

Set objFile = Nothing
Set objFileSystem = Nothing
0
 

Author Comment

by:josgan
ID: 16854369
Awesome, thanks this does exactly what i need.
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 16854578

Pleasure :)

Chris
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Downtime reduced, data recovered by utilizing an Experts Exchange Business Account Challenge The United States Marine Corps employs more than 200,000 active-duty Marines with operations in four continents, all requiring complex networking system…
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question