markwilliamson2001 Posted September 11, 2007 Posted September 11, 2007 Hi! I am new to this forum, but have been reading with keen interest lately! I am trying to do some thing I think is fairly simpe in active directory. I have added a load of bulk users in active directory, but I would like to add the users display name, to the users description, so it appears in the user list. I have looked at dsmod user for this, but cant find any examples allowing me to do what i want to do! Has anyone done this before, or got any ideas? Ta Mark
iatkinson Posted September 11, 2007 Posted September 11, 2007 Haven't used it in a while but you can mod stuff with AD infinitum
Geoff Posted September 11, 2007 Posted September 11, 2007 http://www.edugeek.net/index.php?name=Forums&file=viewtopic&t=403
FN-GM Posted September 11, 2007 Posted September 11, 2007 If you select all the users you want to edit right click > properties you can change the description box.
markwilliamson2001 Posted September 11, 2007 Author Posted September 11, 2007 Yes, but that means I can only update all users with the same description!! I want to match individual users display name to the description, then move onto the next user. P.S. I have 300+ users to do this for!! Kind regards Mark.
saundersmatt Posted September 11, 2007 Posted September 11, 2007 Mark, you'll want to use a tool called ADModify.net It will let you select an OU full of users and fill the description field with the required data. Matt
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 That sounds more like it! Ta Mark
Iain Posted September 12, 2007 Posted September 12, 2007 Or use a very simple vbs script. e.g. Set objRootDSE = GetObject("LDAP://rootDSE") ' Define the Distinguished Name of the Organizational Unit ' containing the users to modify strUserOU = "ou=Students," & objRootDSE.Get("defaultNamingContext") ' Bind to the users OU Set objOU = GetObject ("LDAP://" & strUserOU) ' Set the filter to only return user objects objOU.Filter = Array("user") ' Iterate through the user objects setting the required ' attributes For each objUser in objOU ' Get the user's display name strDisplayName = objUser.displayName ' Set the user's discription = user's display name objUser.Description = strDisplayName objUser.SetInfo Next ' Clean up Set objOU = Nothing Set objRootDSE = Nothing Iain.
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 How can I run this script? Can I create a batch file that points to the vb file, or do I need to do somethign in particular! Thanks for all the help by the way, although I havent managed to get any of the solutions working so far, but this script looks okay! Just need to get it working now!
Iain Posted September 12, 2007 Posted September 12, 2007 Just save the script in a file with a name of your choice and give it a .vbs extension. Then at the command prompt, go to the directory where you have saved the script and type .vbs and it should run. Don't forget to modify the strUserOU variable to point the the OU where you have created the users. Iain.
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 Thanks Iain! Much Appreciated
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 Tried running the script but it came up with an error concerning the objRootLDAP, which it says is required!, not too sure on how to fix this! Mark
Iain Posted September 12, 2007 Posted September 12, 2007 Appologies a mistake on my part, I used the wrong variable name on the line strUserOU = "ou=Students," & objRootLDAP.Get("defaultNamingContext") it should read: strUserOU = "ou=Students," & objRootDSE.Get("defaultNamingContext") Iain
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 Still no luck, now it says that the object (scriptname).vbs, doesnt exist, and I have checked the file name more than once! Mark aarrrrggghhhh!
Iain Posted September 12, 2007 Posted September 12, 2007 Is the error There is no such object on the server.? If so it means you have not defined strUserOU correctly. Iain.
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 It is to do with line 8 char 1 around this area i guess, but objuser is not explicitly defined as such: objUser.Description = strDisplayName objUser.SetInfo which is part of: For each objUser in objOU ' Get the user's display name strDisplayName = objUser.displayName ' Set the user's discription = user's display name objUser.Description = strDisplayName objUser.SetInfo Next Hope this helps, Thanks for all the help so far! This seems like a tedious thing, but the network manager wants it! Mark
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 I also checked out the struserOU, and it matches with a ou called TESTBATCH in an existing OU called Pupil. Not sure if this makes a difference! Ta Mark
Iain Posted September 12, 2007 Posted September 12, 2007 Line 8 Char 1 corresponds to Set objOU = GetObject ("LDAP://" & strUserOU) Which means there is an error when trying to bind to the users OU. If you do a WScript.Echo strUserOU, it should display: ou=TESTBATCH,ou=Pupil, [Assuming the user objects to be modified are in and OU called TESTBATCH which is in an OU called Pupil which is in the domain root]
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 It only displays ou=TESTBATCH,DC=CHASE,DC=local, even though the TESTBATCH ou is inside an existing ou called pupil, which is in the domain root! after the echo, it still crashes, at the same point, line 8 (now line 9). Thanks Mark
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 I have included my current script, modified for your perusa Set objRootDSE = GetObject("LDAP://rootDSE") ' Define the Distinguished Name of the Organizational Unit ' containing the users to modify strUserOU = "ou=TESTBATCH," & objRootDSE.Get("defaultNamingContext") WScript.Echo strUserOU ' Bind to the users OU Set objOU = GetObject ("LDAP://" & strUserOU) ' Set the filter to only return user objects objOU.Filter = Array("user") ' Iterate through the user objects setting the required ' attributes For each objUser in objOU ' Get the user's display name strDisplayName = objUser.displayName ' Set the user's discription = user's display name objUser.Description = strDisplayName objUser.SetInfo Next ' Clean up Set objOU = Nothing Set objRootDSE = Nothing Thanks mark
Iain Posted September 12, 2007 Posted September 12, 2007 Thought that may be the case, strUserOU needs to point to the correct OU of the user objects. Probably my fault for not adding sufficient comments to the script, but objRootLDAP.Get("defaultNamingContext") only returns the distinguished name for the root of the directory, which in your case is DC=CHASE,DC=local So, if you chnage the line strUserOU = "ou=TESTBATCH," & objRootDSE.Get("defaultNamingContext") To read strUserOU = "ou=TESTBATCH,ou=Pupil," & objRootDSE.Get("defaultNamingContext") Hopefully is should work. Iain.
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 Still crashes at Line 9!! Think I am going to give up on this! Thanks for all the help anyway. Mark
Iain Posted September 12, 2007 Posted September 12, 2007 Did you make sure there was a comma after ou=Pupil ?
markwilliamson2001 Posted September 12, 2007 Author Posted September 12, 2007 Thanks that worked a treat! Mark
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