machin05 Posted October 14, 2008 Posted October 14, 2008 (edited) Hi, I need to enter the email addresses for all our staff and students 1000+ within our active directory. For each user their email address will be in the format of %username%@schooldomain.sch.uk This is a different domain name to the one used by active directory. I was hoping you folks know of a way to update user information across the whole domain? At the moment all users email address field in AD is blank. So far I've tried using some software call Active User Manager to highlight multiple users in an OU and update the email address field using the %username%@schooldomain.sch.uk, but once that is applied the value of %username% remains, and doesn't change to j.smith etc. Hope that makes sense, if not fire away with your questions! Any info/advice is greatly appreciated... Cheers, Will Edited October 14, 2008 by machin05
srochford Posted October 14, 2008 Posted October 14, 2008 What email system? I'm guessing not Exchange because that does it for you (you specify the default form of email and the recipient update policy does magic) If it's just storing data in the email address field (not creating mailboxes) then it's easy to script it or admod from Joeware can also do this for you - there's an example here to do exactly what you want.
machin05 Posted October 14, 2008 Author Posted October 14, 2008 Sorry, forgot to mention our email system is our LA supplied Mymail system, which is a webmail based system. I will have a look at those links, cheers.
powdarrmonkey Posted October 14, 2008 Posted October 14, 2008 It's easy; open Active Directory Users and Computers, select the users you want to update, get their properties, and Email to the variable field you have already used, %username%@restofaddress. ADUC will flesh out the username for you. You're not restricted to the domain name AD uses, it's a free-form field. 1
tomscaper Posted October 14, 2008 Posted October 14, 2008 Out of curiosity why do you want to add the email address in the email line in AD, we also use the mymail system and just wondered what you were planning to do.
Stuart_C Posted October 15, 2008 Posted October 15, 2008 It's easy; open Active Directory Users and Computers, select the users you want to update, get their properties, and Email to the variable field you have already used, %username%@restofaddress. ADUC will flesh out the username for you. You're not restricted to the domain name AD uses, it's a free-form field. Can you? Aw rubbish! I spend about an hour on monday using DSQUERY and DSMOD (and Excel!)to populate the E-mail address field for all our users. Though having said that your method is only easy if you have your users in a single or limited number of OU's. If there is a large number of OU's then it's probably easier to use DSQUERY to get the distinguished name of all the users then DSMOD to change them so I don't feel so bad.
CyberNerd Posted October 15, 2008 Posted October 15, 2008 I set tehm like this when we installed our zimbra server Set objParent = GetObject("LDAP://OU=Year CC,DC=College,DC=internal") objparent.Filter = Array("user") for each objUser in objParent 'Wscript.Echo "Modifying " & objUser.Get("sAMAccountName") objUser.put "mail", objUser.Get("sAMAccountName") & "@email.address" objuser.put "targetAddress","SMTP:" & objUser.Get("sAMAccountName") & "@email.address" objuser.put "proxyAddresses", "SMTP:" & objUser.Get("sAMAccountName") & "@email.address" objuser.put "mailNickname", objUser.Get("sAMAccountName") objuser.Setinfo next Wscript.Echo "Done ;)" then ran it on each OU
CyberNerd Posted October 15, 2008 Posted October 15, 2008 Out of curiosity why do you want to add the email address in the email line in AD, we also use the mymail system and just wondered what you were planning to do. If the email is in AD you can use outlook to search and very easily populate external systems such as moodle /various linux servers with that information in AD it's easy to dynamically create mailing groups for class lists etc
powdarrmonkey Posted October 15, 2008 Posted October 15, 2008 Though having said that your method is only easy if you have your users in a single or limited number of OU's. If there is a large number of OU's then it's probably easier to use DSQUERY to get the distinguished name of all the users then DSMOD to change them so I don't feel so bad. Then do a find from the top of your OU tree, search for wildcard, and select the appropriate people from the results.
srochford Posted October 15, 2008 Posted October 15, 2008 Then do a find from the top of your OU tree, search for wildcard, and select the appropriate people from the results. Things like this only work on small networks; my last place had c. 15,000 users in AD. I haven't counted them here but it's easily twice that - selecting them all from a list is non-trivial :-)
Hokalus Posted October 15, 2008 Posted October 15, 2008 We use ADModify to do this sort of thing. Just add the OUs you want to process, tell it what you want to change and it's done in seconds.
machin05 Posted October 15, 2008 Author Posted October 15, 2008 Cheers for all the replies folks. I want to update the email line in AD for use within Moodle. We're in the process of setting it up for our school and you can use that field to auto-complete users for the first time they log into moodle. I will have a look at the different methods for updating AD info that you all have detailed and let you know what works for me. I know this might sound antiquated, but we're still running a Win2000 AD so i believe selecting multiple users is a no-no. Peace
machin05 Posted October 15, 2008 Author Posted October 15, 2008 OK, very quick update. Selecting multiple users works when done from an XP workstation using the Windows 2003 Admin Pack BUT I've just realised that our staff user names are in the format of j.blogs but our email address are [email protected]. Therefore using the %username% tag will enter the incorrect email address. Any ideas on a quick way around this. Maybe using excel files to export, remove the full stops, then update the AD containers? Cheers, Will
powdarrmonkey Posted October 15, 2008 Posted October 15, 2008 You won't be able to do it natively, you'll have to extract and import as you say.
machin05 Posted October 16, 2008 Author Posted October 16, 2008 You won't be able to do it natively, you'll have to extract and import as you say. Thought as much. Any pointers or example scripting will be of great help as my own scripting experience has been gathered on a very ad hoc basis. I can export a list of the users an use excel formula to remove the full stop and append the domain name, but then importing the new values to the correct containers in ad.... GULP! Cheers, Will
CyberNerd Posted October 16, 2008 Posted October 16, 2008 T Any pointers or example scripting will be of great help as my own scripting experience has been gathered on a very ad hoc basis. Can you not see the script that I posted?, you can save it as a .vbs file then run it on each OU by editing the text so that it suits your organisation. It does exactly what you want, we have our moodle fields populated this way.
machin05 Posted October 16, 2008 Author Posted October 16, 2008 Nice on CyberNerd, I've had a look at your script, and it looks like it would do the job apart from the fact our SAMAccountName values don't match up with our email address prefix. For example Steve Bull would have a SAMAccountName of s.bull but an email of [email protected] Is there anyway of tying this script in with an excel file that I could use to remover the full stops? Cheers, Will
CyberNerd Posted October 16, 2008 Posted October 16, 2008 I wrote you a shortened version: this bit sets the LDAP OU that you will search, you must change this: Set objParent = GetObject("LDAP://OU=Year XX,DC=College,DC=internal") this bit says select 'users' rather than computers/groups objparent.Filter = Array("user") for every user that has been selected for each objUser in objParent tell me what is happening (commented out) 'Wscript.Echo "Modifying " & objUser.Get("sAMAccountName") then set teh 'mail' LDAP attribute to that of the accountname + email.address objUser.put "mail", objUser.Get("sAMAccountName") & "@email.address" write the info back to AD objuser.Setinfo go do the next one next
CyberNerd Posted October 16, 2008 Posted October 16, 2008 to select the sirname , the ldap attribute is 'sn' objUser.Get("sn") to find the firstname, it is givenname objUser.Get("givenname") so you just need a way of finding out how to get vbs to strip the first character from the givenname
penfold_99 Posted October 16, 2008 Posted October 16, 2008 Nice on CyberNerd, I've had a look at your script, and it looks like it would do the job apart from the fact our SAMAccountName values don't match up with our email address prefix. For example Steve Bull would have a SAMAccountName of s.bull but an email of [email protected] Is there anyway of tying this script in with an excel file that I could use to remover the full stops? Cheers, Will this line will give you the sAMAccountName without the "." $email = Replace(objUser.Get("sAMAccountName"),".","")) 1
apeo Posted October 16, 2008 Posted October 16, 2008 to select the sirname , the ldap attribute is 'sn' objUser.Get("sn") to find the firstname, it is givenname objUser.Get("givenname") so you just need a way of finding out how to get vbs to strip the first character from the givenname You can use Left to do it i.e. left(objUser.Get("givenname") ,1) but using replace to remove the "." is a cleaner way of coding imo.
machin05 Posted October 16, 2008 Author Posted October 16, 2008 Cheers for all the help chaps, I will definately have a look at the script you've detailed for me. Thanks very much. this line will give you the sAMAccountName without the "." $email = Replace(objUser.Get("sAMAccountName"),".","")) Penfold, how can I incorporate that line into the script that is detailed above? Sorry for being a scripting simpleton! Cheers, Will
machin05 Posted October 16, 2008 Author Posted October 16, 2008 Ok, Ive modified the script but I'm getting an error on the first line, saying there is no such object. Can you tell me what the XX stands for in the example code? My first line reads: Set objParent = GetObject("LDAP://OU=Moodle,OU=Staff,OU=Test,DC=lordswoodgirls,DC=school") Just to clarify, our domain is lordswoodgirls.school and the OU i'm trying this on is called Test, which is in an OU called Staff, which is in an OU call Moodle, which is in the root of the domain. Thanks again, Will
machin05 Posted October 16, 2008 Author Posted October 16, 2008 It seems as soon as I post on here, I realise what a moron I'm being! I've sorted the script, I realise I had the OU's the worng way round! On the off change, is there anyway of forcing it all in lowercase? As it stands I've got an email addresses reading as [email protected]. assume it makes no difference, but I'm funny about things like that! For reference my script looks like this: Set objParent = GetObject("LDAP://OU=Test,OU=Staff,OU=Moodle,DC=lordswoodgirls,DC=school") objparent.Filter = Array("user") for each objUser in objParent 'Wscript.Echo "Modifying " & objUser.Get("sAMAccountName") objUser.put "mail", left(objUser.Get("givenname"),1) & objUser.Get("sn") & "@lordswdg.bham.sch.uk" objuser.Setinfo next Wscript.Echo "Done ;)"
srochford Posted October 16, 2008 Posted October 16, 2008 You can use Left to do it i.e. left(objUser.Get("givenname"),1) but using replace to remove the "." is a cleaner way of coding imo. replace is nice and works well in this specific case. The good thing about getting different examples is that it shows people other options. Our email addresses are of the form .@ etc and for this the "left" function is needed because samaccountname won't give you that at all.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now