Jump to content

Entering email addresses for muliple users in Active Directory


Recommended Posts

Posted

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!

 

 

Use lcase:

 

objUser.put "mail", lcase(left(objUser.Get("givenname"),1) & objUser.Get("sn")) & "@lordswdg.bham.sch.uk"

  • Thanks 1
Posted
Use lcase:

 

objUser.put "mail", lcase(left(objUser.Get("givenname"),1) & objUser.Get("sn")) & "@lordswdg.bham.sch.uk"

 

Thanks a lot mate, perfect.

 

One last question (maybe!), how could I incorporate this line of code for replacing the .

 

$email = Replace(objUser.Get("sAMAccountName"),".",""))

 

Whereabouts does it need to go?

 

Thanks again,

Will

Posted
Thanks a lot mate, perfect.

 

One last question (maybe!), how could I incorporate this line of code for replacing the .

 

$email = Replace(objUser.Get("sAMAccountName"),".",""))

 

Whereabouts does it need to go?

 

Thanks again,

Will

 

Something like this i guess:

 

lcase(Replace(objUser.Get("sAMAccountName"),".","")))

  • Thanks 1
Posted
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.

 

yeah i meant in this case its cleaner to use replace but the other option is always there :D

Posted

Cheers everyone,

 

Got it sorted and working. Have successfully changed all staff entries. Much appreciated.

 

My final script looked like this:

 

Set objParent = GetObject("LDAP://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", lcase(Replace(objUser.Get("sAMAccountName"),".","")) & "@lordswdg.bham.sch.uk"

objuser.Setinfo

next

Wscript.Echo "Done ;)"

 

Thanks again,

Will

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...