Exporting all users in AD

Hi,

I am trying this command and when I run this:

ldifde -f C:\ldif\ExportUsers.ldf –s SERVERNAME -d "OU=YourOUname,dc=YourDomainName,dc=com" -p subtree -r "(objectClass=User)" -l "cn,givenName,Title,SamAccountName"

It tells me this:

ldifde -f C:\ldif\ExportUsers.ldf –s iserve.fs02.iserve.local  -d "OU=User Accounts ,dc=iserve.local ,dc=com" -p subtree -r "(objectClass=User)" -l "cn,givenName,Title,SamAccountName" -j c:\log.txt
 it returns with error:

Invalid parameter bad argument -s.

Kind Regards,

Johan
LVL 4
johanvz1Asked:
Who is Participating?
 
prashsaxConnect With a Mentor Commented:
Have you used csvde.


csvde -f c:\output.csv

It will dump all the users to a comma seperated text file.

Then you can import it using csvde on the other server.

You can open this file in excel as well.


0
 
johanvz1Author Commented:
Hi,

Even in trying basic command eg:

ldifde -f  output.ldf -j c:\log.txt

It returns with unable to open log file.

What format must log file be?.My first time using ldifde.

Rgds,

Johan
0
 
Steve KnightIT ConsultancyCommented:
For starters:

Well silly question #1, have you got NTFS rightrs to create a file at the root of C:\ ?
Your "-d" entry is wrong, should be:

-d "OU=User Accounts,dc=iserve,iserve=local" afaik

Steve
0
Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

 
Steve KnightIT ConsultancyCommented:
or even

-d "OU=User Accounts,dc=iserve,dc=local"
0
 
johanvz1Author Commented:
Hi,

Yes I have rights to the root drive Im logged in directly on the server as Domain Administrator.

Why must you say dc=iserve,dc=local?

Is that too fool it with the FQDN?.

Rgds,

Johan
0
 
Steve KnightConnect With a Mentor IT ConsultancyCommented:
That's just how you specify the queriesm, I believe the above link shows the same format too...

Steve
0
 
johanvz1Author Commented:
I see now let me try it I was probably being dumb.
0
 
johanvz1Author Commented:

C:\>ldifde -f C:\ldif\ExportUsers.ldf -s iserve.fs02 -d "OU=User Accounts ,dc=is
erve ,dc=local" -p subtree -r "(objectClass=User)" -l "cn,givenName,Title,SamAcc
ountName"
Invalid Parameter: Bad argument '-s'

still giving this error


0
 
prashsaxCommented:
ldifde -f C:\ldif\ExportUsers.ldf  -d "OU=User Accounts ,dc=iserve ,dc=local" -p subtree -r "(objectClass=User)"
-l "cn,givenName,Title,SamAccountName"

Run this on the GC(Global Catalog) in your domain.






0
 
johanvz1Author Commented:
What is the global catalog?. sorry for asking dumb question
0
 
prashsaxCommented:
If you have only one domain controller in your site, run this on that.

Global Catalog server is a domain controller which contains all the information about domain.

All I am saying is to run it without -s option.


Also, try one more thing.

Goto on command prompt on one of the domain controller.

Type:
hostname

This will give you some name, copy it and use it as it is with the -s option, instead of using "iserve.fs02".

0
 
johanvz1Author Commented:
what would the exact command be now?.
0
 
prashsaxCommented:
ldifde -f C:\ldif\ExportUsers.ldf  -d "OU=User Accounts ,dc=iserve ,dc=local" -p subtree -r "(objectClass=User)"
-l "cn,givenName,Title,SamAccountName"


AND

ldifde -f C:\ldif\ExportUsers.ldf  -s %COMPUTERNAME% -d "OU=User Accounts ,dc=iserve ,dc=local" -p subtree -r "(objectClass=User)"
-l "cn,givenName,Title,SamAccountName"

Use both.  One should work.

Also, "OU=User Accounts" may not work as this is not an OU its a CN.
So, you should use "CN=User Accounts" instead.
0
 
johanvz1Author Commented:
Hi,

Where would the actual export file be located?. And should I worried about the fact that it keeps asking me about -j log file ?.
0
 
prashsaxCommented:
File would be located at c:\LDIF Folder.

If this folder does not exist on drive C, the either change the -f option to c:\exportusers.ldf
or
Create a folder on drive c: named LDIF.

0
 
johanvz1Author Commented:
When I run it as

ldifde -f C:\ldif\ExportUsers.ldf  -d "CN=User Accounts ,dc=iserve ,dc=local" -p subtree -r "(objectClass=User)"
-l "cn,givenName,Title,SamAccountName"

It does this:

C:\>ldifde -f C:\ldif\ExportUsers.ldf  -d "CN=User Accounts ,dc=iserve ,dc=local
" -p subtree -r "(objectClass=User)"
Connecting to "ise-fs02.iserve.local"
Logging in as current user using SSPI
Exporting directory to file C:\ldif\ExportUsers.ldf
Searching for entries...
Error opening output file.
The error code is 3
An error has occurred in the program
No log files were written.  In order to generate a log file, please
specify the log file path via the -j option.

C:\>-l "cn,givenName,Title,SamAccountName"
'-l' is not recognized as an internal or external command,
operable program or batch file.


0
 
mteskeCommented:
csvde /? would be preferrable...
if you want to export all users to a file that can be imported to another test domain, you can do this...

csvde -f somefile.csv -m  -r "(objectclass=user)"

this will export all users and computers...the -m strips the GUIDS so you can import it into an new domain...I would assume the same syntax would work for ldifde...both methods work, ldifde allows you to modify existing objects...csvde is simply export/import...no modify.

m
0
 
prashsaxCommented:
The error was due to folder does not exist in c:.

Create a folder in drive c:\ and name it LDIF.

This should do the trick.

Also,
>C:\>-l "cn,givenName,Title,SamAccountName"
>'-l' is not recognized as an internal or external command,
>operable program or batch file.

This is incorrect command.

0
 
johanvz1Author Commented:
Hi,

I have run this:


ldifde -f C:\ldif\ExportUsers.ldf  -d "CN=User Accounts ,dc=iserve ,dc=local" -p subtree -r "(objectClass=User)"

It processess successfully now after I have created the folder c:\ldif\

But is says no entries found. And the ExportsUsers.ldf file is empty.
0
 
mteskeCommented:
I would guess that the cn=user accounts should say users?  unless you created an OU named user accounts.  the default container created in AD is called users.  if this is where they are located, try Users, or if it is an OU then do OU=User Accounts.
0
 
mteskeCommented:
oh yeah...are using Small Business server?  is it a nested ou?  if so, then you have to type all the parent ou's.  ie...ou=user accounts, ou=my company,dc=iserve,dc=local.

again, the default "container" is Users...not user accounts...so CN=Users....not CN=User Accounts...
0
 
johanvz1Author Commented:
I have made that change to users but it seems to have extacrec 5 groups and not users. It also has a lot of information I dont need for example I only want username,logon name and if the account is active or disabled and what groups it has membership to. I have windows 2003 server standard edition.
0
 
mteskeConnect With a Mentor Commented:
where exactly do your users reside...the FQDN path...check in the users container and see what is in there...you should have at least exported the administrator account...unless of course you moved it into another OU.

0
 
mteskeCommented:
try simplifying your command as well...see if you can first get the users...without the other switches...and then add 1 switch at a time until you get the desired results...
0
 
johanvz1Author Commented:
Hi,

I have just noticed that by default there exists a Users OU but the previous administrator has also created a OU within the root of the domain called User Accounts and within this OU he has made several containers with users in them. Now the 5 entries which has been written out by the previous export command are those within the oringinal OU eg Administrator and Guest.

I have tried running it with the name for the OU as User Accounts and UserAccounts individually. I am trying to get it all the users withi the containers within this created OU.

I am trying to play around with the syntax might it for some reason pick up the OU with a different text name than the Ou's display name?.

Rgds,

Johan
0
 
johanvz1Author Commented:
CSVDE -d "OU=User Accounts,DC=iserve,dc=local" -f iserve.csv

This has given me all the information I want can I tell from this if the account is disabled or not?. I want to see which counts are disabled or have expired pwd's?.
0
 
mteskeCommented:
what would work better would be to run a vbscript against the domain for the users...otherwise...look at the user account control attribute and "I think" an account control of 512 is disabled.  there is another attribute for expired passwords....but do not know it off the top of my head...hold on.
0
 
zsplblrCommented:
How to export only user created/disabled date with user name?
0
 
ziadsawalhaCommented:
This might be too obvious, but the command in the original post was missing a dash before the s. It should be:
ldifde -f C:\ldif\ExportUsers.ldf -s SERVERNAME -d "OU=YourOUname,dc=YourDomainName,dc=com" -p subtree -r "(objectClass=User)" -l "cn,givenName,Title,SamAccountName"

0
All Courses

From novice to tech pro — start learning today.