Solved

Exporting all users in AD

Posted on 2006-06-26
30
6,483 Views
Last Modified: 2009-03-04
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
0
Comment
Question by:johanvz1
  • 12
  • 6
  • 6
  • +4
30 Comments
 
LVL 4

Author Comment

by:johanvz1
ID: 16983858
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16984236
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16984254
or even

-d "OU=User Accounts,dc=iserve,dc=local"
0
 
LVL 30

Expert Comment

by:ded9
ID: 16984269
0
 
LVL 4

Author Comment

by:johanvz1
ID: 16984334
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
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 50 total points
ID: 16984371
That's just how you specify the queriesm, I believe the above link shows the same format too...

Steve
0
 
LVL 4

Author Comment

by:johanvz1
ID: 16984499
I see now let me try it I was probably being dumb.
0
 
LVL 13

Accepted Solution

by:
prashsax earned 300 total points
ID: 16984516
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16984527

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
 
LVL 13

Expert Comment

by:prashsax
ID: 16984700
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16984750
What is the global catalog?. sorry for asking dumb question
0
 
LVL 13

Expert Comment

by:prashsax
ID: 16984851
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16984894
what would the exact command be now?.
0
 
LVL 13

Expert Comment

by:prashsax
ID: 16984962
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16985082
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
 
LVL 13

Expert Comment

by:prashsax
ID: 16985113
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16985187
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
 

Expert Comment

by:mteske
ID: 16985192
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
 
LVL 13

Expert Comment

by:prashsax
ID: 16985258
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16985805
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
 

Expert Comment

by:mteske
ID: 16985831
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
 

Expert Comment

by:mteske
ID: 16985852
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16985886
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
 

Assisted Solution

by:mteske
mteske earned 150 total points
ID: 16985900
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
 

Expert Comment

by:mteske
ID: 16985911
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16986031
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
 
LVL 4

Author Comment

by:johanvz1
ID: 16986276
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
 

Expert Comment

by:mteske
ID: 16986520
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
 

Expert Comment

by:zsplblr
ID: 23372177
How to export only user created/disabled date with user name?
0
 

Expert Comment

by:ziadsawalha
ID: 23796819
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

Join & Write a Comment

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

759 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now