Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Search Today's Posts Mark Forums Read

Learning Network Manager

Learning Network Manager forum sponsored by
Learning Network Manager Forum Sponsored by ETB-Tech.com

Here you can get support for Microsoft's Learning Network Manager, a free tool that Microsoft will not provide support for as this comes from resellers. But Microsoft agreed to let use have a copy to upload on understanding that we provide any support for it.

Go Back   EduGeek.net Forums > Technical > Learning Network Manager
Reply
 
LinkBack Thread Tools Search Thread Language
Sponsored Links
Old 22-04-2008, 12:41 PM   #1
 
tri_94's Avatar
 
Join Date: Feb 2007
Location: Lincolnshire
Posts: 24
uk uk lincoln
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0 tri_94 is an unknown quantity at this point
Send a message via MSN to tri_94 Send a message via Yahoo to tri_94
Default Exporting From Active Directory

Hi there, i need to export some information from AD,

and i require the following

mailnickname
Email Address
USNCHANGED

i've tried CSVDE -f C:\export.csv -l "mailnickname,mail,usnchanged"

however i only get the mailnickname and the mail information

any ideas anyone.

thanks
nick
  Reply With Quote
Old 22-04-2008, 02:42 PM   #2
 
Geoff's Avatar
 
Join Date: Jun 2005
Location: Fylde, Lancs, UK.
Posts: 9,840
uk uk lancashire
Thanks: 41
Thanked 217 Times in 198 Posts
Blog Entries: 1
Rep Power: 64 Geoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud of
Send a message via ICQ to Geoff Send a message via AIM to Geoff Send a message via MSN to Geoff Send a message via Yahoo to Geoff Send a message via Skype™ to Geoff
Default

What is your domains functional level?
  Reply With Quote
Old 22-04-2008, 02:54 PM   #3
 
altecsole's Avatar
 
Join Date: Jun 2005
Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 altecsole will become famous soon enough
Default

You could run the following vbscript. Just change the domain name and OU info to suit your domain. Doing it this way allows you to run it for each OU. Hope this helps.

Code:
Const DOMAIN = "dc=your_domain,dc=your_area,dc=sch,dc=uk"
Const TOPLEVEL_OU = "ou=School Users"
Const LEVEL1_OU = "ou=Staff Accounts"
Const LEVEL2_OU = "ou=staff2"

Dim objOU
Dim strOUPath
Dim user
Dim strDictUser
Dim objUSNChanged, dblUSNChanged

On Error Resume Next

strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
Set objOU = GetObject _
	("LDAP://" & strOUPath)

For Each user In objOU
	WScript.Echo "Username: " & user.sAMAccountName
	WScript.Echo "Mail nickname: " & user.mailNickname
	WScript.Echo "Email: " & user.mail
	Set objUSNChanged = user.Get("uSNChanged")
	dblUSNChanged = Abs(objUSNChanged.HighPart * (2^32) + objUSNChanged.LowPart)
	WScript.Echo "USNChanged: " & dblUSNChanged & VbCrLf
Next

Set objOU = nothing
Set dblUSNChanged = nothing
  Reply With Quote
Old 22-04-2008, 02:57 PM   #4
 
tri_94's Avatar
 
Join Date: Feb 2007
Location: Lincolnshire
Posts: 24
uk uk lincoln
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0 tri_94 is an unknown quantity at this point
Send a message via MSN to tri_94 Send a message via Yahoo to tri_94
Default

sorry new to this part, what do you mean?
  Reply With Quote
Old 22-04-2008, 04:00 PM   #5
 
altecsole's Avatar
 
Join Date: Jun 2005
Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 altecsole will become famous soon enough
Default

Quote:
Originally Posted by tri_94 View Post
sorry new to this part, what do you mean?
PM me with your domain name and the OU containing the users that you want to get the info for. If it's a sub OU I'll need the name of the OUs above it. I'll edit the script so you can see what I mean.
  Reply With Quote
Old 22-04-2008, 04:07 PM   #6
 
Geoff's Avatar
 
Join Date: Jun 2005
Location: Fylde, Lancs, UK.
Posts: 9,840
uk uk lancashire
Thanks: 41
Thanked 217 Times in 198 Posts
Blog Entries: 1
Rep Power: 64 Geoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud ofGeoff has much to be proud of
Send a message via ICQ to Geoff Send a message via AIM to Geoff Send a message via MSN to Geoff Send a message via Yahoo to Geoff Send a message via Skype™ to Geoff
Default

Quote:
Originally Posted by tri_94 View Post
sorry new to this part, what do you mean?
Technet - What Are Active Directory Functional Levels?

You need a minimum domain functional level of Windows 2000 native otherwise usnchanged is not recorded in AD.

Additionally, usnchanged is not replicated, so you must always query the same DC.

Polling for Changes Using USNChanged (Windows)
  Reply With Quote
Old 23-04-2008, 12:30 PM   #7
 
tri_94's Avatar
 
Join Date: Feb 2007
Location: Lincolnshire
Posts: 24
uk uk lincoln
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0 tri_94 is an unknown quantity at this point
Send a message via MSN to tri_94 Send a message via Yahoo to tri_94
Default

Hi there again, sorry to be so vague about this.

We are installing some software called Safe com for monitoring printing and our finance officer has agreed to trial a system called pull printing. which is were the pupils have a pin number and they type in at the printer and then it slows a list of what they have sent to print and then you can choose which you like.

So I've got a choice of supplying a csv file with all pupils names and email addresses and a pin number. however if i can use the USNChanged number i can integrate it to create a pin when i create a new user rather then manually doing it.

So what i require is to export details such as mailnickname, (which is our pupils usernames) and mail (which is our email address). and also I've seen that the uSNChanged is a unique number..

I'm a bit of a beginner to most of the AD side of things as we have a RM network here.

from what i understand this will be the information i will need to use ?

OU=Domain Controllers,DC=cordeauxcc,DC=internal

OU=Establishments,OU=Domain Controllers,DC=cordeauxcc,DC=internal

OU=Students,OU=CHS,OU=Establishments,DC=cordeauxcc ,DC=internal

DC=cordeauxcc,DC=internal

thanks for any help
nick
  Reply With Quote
Old 23-04-2008, 01:41 PM   #8
 
altecsole's Avatar
 
Join Date: Jun 2005
Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 altecsole will become famous soon enough
Default

Okay, give this a try.

Copy the code into Notepad and save it as a .vbs file. Open a cmd prompt and run the script.

It'll write the result to a csv file in the same directory as the one the script is run from.

I'm not sure that USNChanged is the value you want as this will change when user attributes change. You could generate auto numbers in Excel?

Let me know if you have any problems.

Code:
'==========================================================================
' NAME: ExportDetails.vbs
'
' AUTHOR: Jim Williams
' DATE  : 29/02/2008
'
' COMMENT: Gets username, email and USNChanged values for users in OU
'==========================================================================
Option Explicit

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim objShell
Set objShell = CreateObject("Wscript.Shell")
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Set log file path to current directory
Dim strLogFilePath, openFile
strLogFilePath = objShell.CurrentDirectory & "\ExportDetails.csv"

'Check if file exists, if not; create and add headings
If (objFSO.FileExists(strLogFilePath)) Then
	WScript.Echo "The Export File already exists. Rename, or move the file, and run again."
	WScript.Echo "Exiting..."
	WScript.Quit
	'Exit
Else
	Set openFile = objFSO.OpenTextFile(strLogFilePath, ForWriting, True)
	openFile.WriteLine "Username, Email, USNChanged"
	openFile.Close
End If

Dim strReport
strReport = GetUserInfo()

'write report to file
Set openFile = objFSO.OpenTextFile(strLogFilePath, ForAppending, True)
openFile.Write strReport
openFile.Close
WScript.Echo "Complete. Export file written to " & strLogFilePath

'tidy up
Set objShell = Nothing
Set objFSO = Nothing

Function GetUserInfo()
	Const DOMAIN = "dc=cordeauxcc,dc=internal"
	Const TOPLEVEL_OU = "ou=Establishments"
	Const LEVEL1_OU = "ou=CHS"
	Const LEVEL2_OU = "ou=Students"
	
	Dim objOU, strOUPath, user
	Dim objUSNChanged, dblUSNChanged
	Dim strMyReport
	
	On Error Resume Next
	
	strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
	Set objOU = GetObject _
		("LDAP://" & strOUPath)
	For Each user In objOU
		Set objUSNChanged = user.Get("uSNChanged")
		dblUSNChanged = Abs(objUSNChanged.HighPart * (2^32) + objUSNChanged.LowPart)
		strMyReport = strMyReport & user.sAMAccountName & ", " & user.mail & ", " & dblUSNChanged & VbCrLf
	Next
	'tidy and return
	Set objOU = Nothing
	Set objUSNChanged = Nothing
	GetUserInfo = strMyReport
	
End Function

Last edited by altecsole; 23-04-2008 at 01:47 PM..
  Reply With Quote
The Following User Says Thank You to altecsole For This Useful Post:
speckytecky (23-04-2008)
Old 24-04-2008, 01:57 PM   #9
 
tri_94's Avatar
 
Join Date: Feb 2007
Location: Lincolnshire
Posts: 24
uk uk lincoln
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0 tri_94 is an unknown quantity at this point
Send a message via MSN to tri_94 Send a message via Yahoo to tri_94
Default

hi there tried that and it worked for some however i noticed that within the OU students I've got other OU groups

how can i modify it to include these ou groups aswell?

Sixth Form
2000
2001
2002
2003
2004
2005
2006
2007

thanks
nick
  Reply With Quote
Old 24-04-2008, 02:40 PM   #10
 
altecsole's Avatar
 
Join Date: Jun 2005
Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 altecsole will become famous soon enough
Default

Quote:
Originally Posted by tri_94 View Post
hi there tried that and it worked for some however i noticed that within the OU students I've got other OU groups

how can i modify it to include these ou groups aswell?

Sixth Form
2000
2001
2002
2003
2004
2005
2006
2007

thanks
nick
Okay, you need to add another sub OU to your constants; like this:

Code:
	Const DOMAIN = "dc=cordeauxcc,dc=internal"
	Const TOPLEVEL_OU = "ou=Establishments"
	Const LEVEL1_OU = "ou=CHS"
	Const LEVEL2_OU = "ou=Students"
	Const LEVEL3_OU = "ou=Sixth Form"
Then change the code further down so that you can run the program for the Student OU or the sub OUs. If you have an entry for LEVEL3_OU to match the name of your sub OUs within Students it will work on that sub OU, or leave as "" to run it against the Students OU only (hope that makes sense!).

Change code to:
Code:
	If LEVEL3_OU = "" Then
		strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
	Else
		strOUPath = LEVEL3_OU & "," & LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
	End If
Here is the complete code, in case that's confusing:
Code:
'==========================================================================
' NAME: ExportDetails.vbs
'
' AUTHOR: Jim Williams
' DATE  : 29/02/2008
'
' COMMENT: Gets username, email and USNChanged values for users in OU
'==========================================================================
Option Explicit

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim objShell
Set objShell = CreateObject("Wscript.Shell")
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Set log file path to current directory
Dim strLogFilePath, openFile
strLogFilePath = objShell.CurrentDirectory & "\ExportDetails.csv"

'Check if file exists, if not; create and add headings
If (objFSO.FileExists(strLogFilePath)) Then
	WScript.Echo "The Export File already exists. Rename, or move the file, and run again."
	WScript.Echo "Exiting..."
	WScript.Quit
	'Exit
Else
	Set openFile = objFSO.OpenTextFile(strLogFilePath, ForWriting, True)
	openFile.WriteLine "Username, Email, USNChanged"
	openFile.Close
End If

Dim strReport
strReport = GetUserInfo()

'write report to file
Set openFile = objFSO.OpenTextFile(strLogFilePath, ForAppending, True)
openFile.Write strReport
openFile.Close
WScript.Echo "Complete. Export file written to " & strLogFilePath

'tidy up
Set objShell = Nothing
Set objFSO = Nothing

Function GetUserInfo()
	Const DOMAIN = "dc=cordeauxcc,dc=internal"
	Const TOPLEVEL_OU = "ou=Establishments"
	Const LEVEL1_OU = "ou=CHS"
	Const LEVEL2_OU = "ou=Students"
	Const LEVEL3_OU = "ou=Sixth Form"
	
	Dim objOU, strOUPath, user
	Dim objUSNChanged, dblUSNChanged
	Dim strMyReport
	
	On Error Resume Next
	
	If LEVEL3_OU = "" Then
		strOUPath = LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
	Else
		strOUPath = LEVEL3_OU & "," & LEVEL2_OU & "," & LEVEL1_OU & "," & TOPLEVEL_OU & "," & DOMAIN
	End If
	
	Set objOU = GetObject _
		("LDAP://" & strOUPath)
	For Each user In objOU
		Set objUSNChanged = user.Get("uSNChanged")
		dblUSNChanged = Abs(objUSNChanged.HighPart * (2^32) + objUSNChanged.LowPart)
		strMyReport = strMyReport & user.sAMAccountName & ", " & user.mail & ", " & dblUSNChanged & VbCrLf
	Next
	'tidy and return
	Set objOU = Nothing
	Set objUSNChanged = Nothing
	GetUserInfo = strMyReport
	
End Function
  Reply With Quote
The Following User Says Thank You to altecsole For This Useful Post:
leeshellard (05-06-2008)
Old 24-04-2008, 03:05 PM   #11
 
tri_94's Avatar
 
Join Date: Feb 2007
Location: Lincolnshire
Posts: 24
uk uk lincoln
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0 tri_94 is an unknown quantity at this point
Send a message via MSN to tri_94 Send a message via Yahoo to tri_94
Default

hi there, tried that and it worked fine for the Sixth Form and also 2007, yet it didn't work for 2006 or 2005. so I've exported the entire AD to csv and uploaded it adusers.rar.

hope someone can work out where I've gone wrong

thanks
nick
Attached Files
File Type: rar adusers.rar (432.5 KB, 5 views)
  Reply With Quote
Old 24-04-2008, 03:19 PM   #12
 
altecsole's Avatar
 
Join Date: Jun 2005
Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 altecsole will become famous soon enough
Default

Quote:
Originally Posted by tri_94 View Post
hi there, tried that and it worked fine for the Sixth Form and also 2007, yet it didn't work for 2006 or 2005. so I've exported the entire AD to csv and uploaded it adusers.rar.

hope someone can work out where I've gone wrong

thanks
nick
Looking at your AD structure I can't see any reason why it wouldn't work.

Did you set the Const correctly? You need to make sure you have the 'ou=' bit in as well. So, for 2005, you should have:

Code:
Const LEVEL3_OU = "ou=2005"
  Reply With Quote
The Following User Says Thank You to altecsole For This Useful Post:
tri_94 (24-04-2008)
Old 24-04-2008, 03:35 PM   #13
 
tri_94's Avatar
 
Join Date: Feb 2007
Location: Lincolnshire
Posts: 24
uk uk lincoln
Thanks: 2
Thanked 1 Time in 1 Post
Rep Power: 0 tri_94 is an unknown quantity at this point
Send a message via MSN to tri_94 Send a message via Yahoo to tri_94
Default

hi there, yeah got it working, i wasnt waiting long enough for the export. many thanks for all your help

cheers
nick
  Reply With Quote
Old 24-04-2008, 03:42 PM   #14
 
altecsole's Avatar
 
Join Date: Jun 2005
Location: Lancaster, Lancashire, UK.
Posts: 190
Thanks: 3
Thanked 10 Times in 10 Posts
Rep Power: 8 altecsole will become famous soon enough
Default

Quote:
Originally Posted by tri_94 View Post
hi there, yeah got it working, i wasnt waiting long enough for the export. many thanks for all your help

cheers
nick
No problem, glad I could help.
  Reply With Quote
Reply

Register now for FREE and post messages!


Username: Password: Confirm Password: E-Mail: Confirm E-Mail:
Birthday:      
Image Verification
  I agree to forum rules 

Similar Threads
Thread Thread Starter Forum Replies Last Post
Active Directory question ClaireL Windows 14 19-05-2008 12:38 PM
"Active Directory time error" when binding OS X Server 10.5 to Active Directory localzuk Mac 7 31-01-2008 01:17 PM
Active Directory Problem clarky2k3 Windows 12 24-01-2008 10:58 AM
active directory all messed up alonebfg Windows 2 07-01-2008 09:25 PM
PDA and Active Directory localzuk Windows 4 10-10-2007 03:54 PM



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search Thread
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +1. The time now is 10:07 AM.
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright EduGeek.net