+ Post New Thread
Results 1 to 14 of 14
Windows Server 2000/2003 Thread, AD - Modiifying Exisitng Users in Technical; Hi All We need to modify all of the Student Users properties within our AD We need to add the ...
  1. #1

    Join Date
    Jul 2009
    Location
    Wolverhampton
    Posts
    116
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    AD - Modiifying Exisitng Users

    Hi All

    We need to modify all of the Student Users properties within our AD

    We need to add the Student Number to the Description Box of each student.

    For a user name we use, First inital, First 4 letters of their Surname and the student number.

    example - jblog12345

    We think it is possible to create a VB or Batch script to check each user, take the number from their user name and add it to the Description Box for each student.

    But not sure how to do it

    Any Advice?

    Thanks

    Phil

  2. #2


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,692
    Thank Post
    352
    Thanked 797 Times in 716 Posts
    Rep Power
    347
    Are the student numbers the same length?

  3. #3

    Join Date
    Jul 2009
    Location
    Wolverhampton
    Posts
    116
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by kmount View Post
    Are the student numbers the same length?
    With in reason

    There are some student numbers that are only 4 numbers long.

    But my thinking was that all students have 5 letters at the start of the user name.

    so its either the 4 or 5 numbers that need to be taken.

    Thanks

    Phil

  4. #4
    TheLibrarian
    Guest
    What should the description contain? Just the student number?

  5. #5

    Join Date
    Jul 2009
    Location
    Wolverhampton
    Posts
    116
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    yeah all i need

    each username, take the last 4 or 5 numbers and copy this in the desciption field

  6. #6


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,692
    Thank Post
    352
    Thanked 797 Times in 716 Posts
    Rep Power
    347
    Easiest way really I can see is to use David's excellent Bulk AD Users utility that will read your AD tree and open it up in a spreadsheet (Excel only I'm afraid) and then you can use some excel foo in the description field such as =RIGHT(A1,5) to strip jblog12345 to 12345 and then import it back in.

    Of course, take many back ups and double triple check what you're doing before you commit it back in.

    http://www.wisesoft.co.uk/userdata/a...Users_Main.png

    http://www.wisesoft.co.uk/software/b...s/default.aspx


    EDIT: Be very careful with the "force password change at logon" tick box

  7. #7

    Join Date
    Jul 2009
    Location
    Wolverhampton
    Posts
    116
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    what happens if you import users that are already there?

  8. #8


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,692
    Thank Post
    352
    Thanked 797 Times in 716 Posts
    Rep Power
    347
    It will update them, test it on a test OU first.

  9. #9
    TheLibrarian
    Guest

    I have not tested this use it at your own risk!

    I have not tested this use it at your own risk!

    filename:StudentNumber.bat
    Code:
    @echo off
    setlocal ENABLEDELAYEDEXPANSION
    for /f %%i in ( 'dsquery user "OU=Pupils,DC=[domain],DC=[domain],DC=[domain],DC=[domain]" -samid * -limit 5 ^| dsget user -samid ^| findstr /i /v /c:"dsget"' ) do (
    set fullsamid=%%i
    set studentnumber=!fullsamid:~5!
    dsquery user -samid !fullsamid! | dsmod user -desc !studentnumber!
    )
    The code above will only target the first 5 accounts it finds in (or under) the Pupils OU, change the 5 after the -limit once you are sure it works.

    You must change the DC=[domain] entries to fit your domain before this will work at all.

    Please test this with the limit of 5 or less so that if it does completely go off the rails (it shouldn't but just in case) you only have 5 broken accounts.

    Once more....

    I have not tested this use it at your own risk!

  10. #10

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    783
    Thank Post
    1
    Thanked 33 Times in 31 Posts
    Rep Power
    24
    THIS HAS NOT BEEN TESTED

    This VB Script will trawl through all user account in the defined OU and set the Description property to "New Description"

    You will need modify the code to read the vairable strChange from the output of a csv or text file that you create using Excel to formulate the required values for the description.

    Simples!

    Code:
    Option Explicit
    DIM objConnection, objCommand, objRecordSet, objUser 
    DIM strChange, strADsPath, strProperty
    strProperty = "Description"
    strChange ="New Description"
    
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"
    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection
    
    objCommand.CommandText = _
    "<LDAP://ou=YOURDOMAIN, dc=cp,dc=com>;" & _
    "(&(objectCategory=person)(objectClass=user));" & _
    "ADsPath;subtree"
    
    Set objRecordSet = objCommand.Execute
    
    DO 
    strADsPath = objRecordset.Fields("ADsPath")
    Set objUser = GetObject(strADsPath)
    objUser.Put strProperty, strChange
    objUser.SetInfo
    objRecordset.MoveNext
    
    Loop Until objRecordset.EOF
    
    Wscript.Echo objRecordSet.RecordCount & _
    " User accounts " & strProperty & " changed to " & strChange
    
    objConnection.Close
    Wscript.quit

  11. #11
    TheLibrarian
    Guest
    Is it good or bad that the OP has gone silent?

  12. #12

    Join Date
    Jul 2009
    Location
    Wolverhampton
    Posts
    116
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I am still here

    lots of things on currently, but have a technician trying this on a test network - nothing is broken.................. yet!!!

    thanks guys will get these tired

  13. #13
    TheLibrarian
    Guest
    Quote Originally Posted by fil_b View Post
    I am still here

    lots of things on currently, but have a technician trying this on a test network - nothing is broken.................. yet!!!

    thanks guys will get these tired
    I was just hoping that I hadn't caused a major headache for you if you'd tried my script.

  14. #14

    Join Date
    Jul 2009
    Location
    Wolverhampton
    Posts
    116
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by TheLibrarian View Post
    I was just hoping that I hadn't caused a major headache for you if you'd tried my script.
    lol

    no its cool dude

    we have a 2008 test network that we can be working with.

    thanks and will keep you posted

SHARE:
+ Post New Thread

Similar Threads

  1. Add More Drives To An exisitng Raid 5 Array
    By FN-GM in forum Hardware
    Replies: 7
    Last Post: 6th May 2011, 08:54 AM
  2. FAO: ELGG users and Moodle Users
    By thegrassisgreener in forum Virtual Learning Platforms
    Replies: 18
    Last Post: 3rd July 2009, 07:12 PM
  3. Replies: 5
    Last Post: 10th February 2009, 05:33 PM
  4. Old Users
    By TechMonkey in forum MIS Systems
    Replies: 7
    Last Post: 15th October 2008, 11:48 AM
  5. New users
    By Dos_Box in forum General Chat
    Replies: 4
    Last Post: 3rd July 2005, 09:44 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •