Page 1 of 1 1
Topic Options
#165130 - 2006-07-27 05:38 PM LDIFDE Help
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Anyone an expert on using the LDIFDE command ? I am trying to formulate a command string to do the following:

1) Dump (export) a single specific user account (a specific SamAccountName) from AD into a file.

2) Assume I dont know what OU its in - but I know his root OU.

Been browsing and surfing and cant seem to nail it - it looks to me like LDIFDE would have to do some kind of recursive search through the OUs for the account. Thought there had to be a more direct way than that.

-Shawn

Top
#165131 - 2006-07-27 06:59 PM Re: LDIFDE Help
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Code:
strDomainName = "NetBIOS Domain Name"

ADname = GetfullName("SamAccountName")

Function GetFullName(strNT4Name)
On Error Resume Next
Err.Clear

Set objTrans = CreateObject("NameTranslate")
objTrans.Init 3, ""
objTrans.Set 3, strDomainName & "\" & strNT4Name
GetFullName = objTrans.Get(1)

End Function



this is VBscript to get a distinguished name from a SamAccountName. Let me know if you need any help to convert it

Top
#165132 - 2006-07-27 07:30 PM Re: LDIFDE Help
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well, I have the SamAccountName ... I'm trying to use the ldifde utility to get the exported settings file that is created.
Top
#165133 - 2006-07-27 07:31 PM Re: LDIFDE Help
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I have already written that UDF - Translatename().
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#165134 - 2006-07-27 07:33 PM Re: LDIFDE Help
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Quote:

LDIFDE COMMANDS:

1. Command to export the user with a given name of SAM Account

ldifde -f exportuser.ldf -s computer_name -r (samaccountname=SAMLNAME)

2. Command to export Organizational Units:

Running this command exports all OUs except domain controllers into a file named ExportOU.ldf.
ldifde -f exportOu.ldf -s Server1 -d "dc=Export,dc=com" -p subtree -r "(objectClass=organizationalUnit)" -l "cn,objectclass,ou"

3. Export the User Accounts from the Source Domain

ldifde -f Exportuser.ldf -s Server1 -d "dc=Export,dc=com" -p subtree -r "(&(objectCategory=person)(objectClass=User)(givenname=*))" -l "cn,givenName,objectclass,samAccountName"
Running this command exports all users in the Export domain into a file named Exportuser.ldf. If you do not have all the required attributes, the import operation does not work. The attributes objectclass and samAccountName are required, but more can be added as needed.

4. Command to Import users from a LDF file:

ldifde -i -f Exportuser.ldf -s Server2

5. Exporting User Account attributes except attributes those can’t be imported: (Using –o switch)

This is another example filter that will export all User Account data except for the attributes that cannot be imported:

ldifde -f Exportuser.ldf -s <Server1> -d "dc=Export,dc=com" -p subtree -r "(&(objectCategory=person)(objectClass=User)(givenname=*))" -o "badPasswordTime,badPwdCount,lastLogoff,lastLogon,logonCount, memberOf,objectGUID,objectSid,primaryGroupID,pwdLastSet,sAMAccountType"

Another Example: To export for any given SamAccountName:

ldifde -f Exportuser.ldf -s <Server1> -d "dc=Export,dc=com" -p subtree -r "(&(objectCategory=person)(objectClass=User)(givenname=*))" -o "badPasswordTime,badPwdCount,lastLogoff,lastLogon,logonCount, memberOf,objectGUID,objectSid,primaryGroupID,pwdLastSet,sAMAccountType"




_________________________
Home page: http://www.kixhelp.com/hb/

Top
#165135 - 2006-07-27 08:19 PM Re: LDIFDE Help
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Thanks Howard/Rogier ... don't tell me thats the command line help ? Anyway, once I can get back into our Network, will try it.
Top
#165136 - 2006-07-27 08:47 PM Re: LDIFDE Help
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yeeessss ... works a champ.
Top
#165137 - 2006-07-27 09:14 PM Re: LDIFDE Help
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
That info came from the Microsoft KB.
Code:
Article ID : 555636 
Last Review : June 6, 2006
Revision : 1.0



Edited by Howard Bullock (2006-07-27 09:15 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#165138 - 2006-07-27 10:03 PM Re: LDIFDE Help
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You could use fnLDAPQuery() as well.
Top
#165139 - 2006-07-27 11:18 PM Re: LDIFDE Help
NTDOC Administrator Online   content
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Quote:

You could use fnLDAPQuery() as well.




Maybe, but can we trust the author to do updates when needed.
He has not updated fnGetFolderProp() yet

Top
#165140 - 2006-07-28 12:20 AM Re: LDIFDE Help
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The beauty of code in the public domain is that you can update it yourself and not have to rely on the original author.
Top
#165141 - 2006-07-28 01:23 AM Re: LDIFDE Help
NTDOC Administrator Online   content
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Yep, true. But not easy for noobs who come across it and try to follow my suggestions of using:

$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')


Thus much nicer if the author updates their UDF to meet that criteria per guidelines.

Top
#165142 - 2006-07-28 02:21 AM Re: LDIFDE Help
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Well, unfortunately summer isn't a good time. I'm busy with my family and my job has me writing a lot of SQL scripts.
Top
#165143 - 2006-07-28 02:38 AM Re: LDIFDE Help
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Yep, true. But not easy for noobs who come across it and try to follow my suggestions...



I guess they may have to stop following your suggestions.

And the guidelines are not retroactive.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.112 seconds in which 0.081 seconds were spent on a total of 11 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org