Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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.

Posted

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!

Posted

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.

Posted

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

Posted

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

Posted

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]

Posted

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

Posted

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

Posted

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.

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...