Announcement

Collapse
No announcement yet.

Changing AD display Names

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing AD display Names

    Hi All,

    Our current AD structure shows user accounts as their logins (which in our case is their 4 digit extension numbers) - I want to change all of these to be their display name so it's easier to locate users by name rather than having to link their ext to their name. we have over 500 users so is gonna be a pain doing everyone seperately.

    Any one know of any DSQUERY and DSMOD combintaions to change the name to their display names??

    All servers are windows 2003

    Thanks

    Michael
    Michael Armstrong
    www.m80arm.co.uk
    MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

  • #2
    Hi Michael,

    MS have an KB article which kinds of helps if you know how to script you can change it around a bit. - http://support.microsoft.com/kb/277717/EN-US/

    I've knocked this VBS script together which maybe more use, I presumed that you do not have the display names in any of the account properties and figured you would need to create a text list anyway. This script reads from the text file c:\exttousr.txt which is in the format

    123, FirstName Lastname
    321, Joe Bloggs

    etc

    It then searches the OU test in mydomain.co.uk for matching ext numbers then changes the display name.

    Give me a shout if you need anything else - Enjoy!!

    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"

    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection

    Const ForReading = 1

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile _
    ("c:\exttousr.txt", ForReading)

    Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , ",")
    Wscript.Echo "Extension: " & arrServiceList(0) & " Is User : " & arrServiceList(1)
    vFullname = arrServiceList(1)

    objCommand.CommandText = _
    "<LDAP://OU=test, DC=mydomain, DC=co, DC=uk>;(&(objectCategory=User)" & _
    "(displayname=" & arrServiceList(0) & "));ADsPath;Subtree"

    Set objRecordSet = objCommand.Execute

    Do Until objRecordset.EOF
    strADsPath = objRecordset.Fields("ADsPath")
    Set objUser = GetObject(strADsPath)
    objUser.Put "displayName", vFullName
    objUser.SetInfo
    objRecordSet.MoveNext
    Loop

    Loop

    objConnection.Close

    You obvously need to change the LDAP path to your domain\OU structure.

    I've run this on my test domain and it works fine, I can't take responsibility for any misuse or problems (although there's nothing to it really.)

    P.S. You may want run this from cscript unless you want 500 pop-up messages !!
    * Shamelessly mentioning "Don't forget to add reputation!"

    Comment


    • #3
      The Display Name contains the users full name which is not affected.

      It looks like it's the Full Name field which requires changing i.e. copy contents of display name and put in real name - if you know what I mean.

      I will take a look at the script

      Another thing - aint done much with scripting before so how do set-up and run these scripts

      Thanks

      Michael
      Michael Armstrong
      www.m80arm.co.uk
      MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

      ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

      Comment


      • #4
        Even Easier !!

        Set objConnection = CreateObject("ADODB.Connection")
        objConnection.Open "Provider=ADsDSOObject;"

        Set objCommand = CreateObject("ADODB.Command")
        objCommand.ActiveConnection = objConnection

        objCommand.CommandText = _
        "<LDAP://OU=test, DC=mydomain, DC=co, DC=uk>;(&(objectCategory=User)" & _
        "(displayname=*));ADsPath;Subtree"

        Set objRecordSet = objCommand.Execute

        Do Until objRecordset.EOF
        strADsPath = objRecordset.Fields("ADsPath")
        Set objUser = GetObject(strADsPath)
        vFullName = objUser.get ("displayName")
        objUser.Put "cn", vFullName
        objUser.SetInfo
        objRecordSet.MoveNext
        Loop

        objConnection.Close

        Topper
        * Shamelessly mentioning "Don't forget to add reputation!"

        Comment


        • #5
          Hi Michael,

          VBS files can just be run by double click the file, which will use the WS engine, and messages will come up as window pop-ups.

          You can also run them by the command line using cscript "vbscript.vbs" which uses the Clengine, any messages will just be outputted to the cmd shell which is easier is there are going to be many messages.

          Topper
          * Shamelessly mentioning "Don't forget to add reputation!"

          Comment


          • #6
            Topper,

            Thanks for the reply again.

            I have set this up on my test network but get the following error:

            " The directory service cannot perform the requested operation on the RDN attributoe of an object"

            All I have changed in the OU it searches.

            I had added some test users and all servers are 2003 SP1

            Michael
            Michael Armstrong
            www.m80arm.co.uk
            MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

            ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

            Comment


            • #7
              Hi,

              Sorry Mate, I didn't double check that last script.

              CN (Fullname) cannot be changed by the LDAP .put, it must be changed using movehere.

              See script below.

              -------------------------------------------------------------------

              Set objConnection = CreateObject("ADODB.Connection")
              objConnection.Open "Provider=ADsDSOObject;"

              Set objCommand = CreateObject("ADODB.Command")
              objCommand.ActiveConnection = objConnection

              objCommand.CommandText = _
              "<LDAP://OU=test, DC=mydomain, DC=co, DC=uk>;(&(objectCategory=User)" & _
              "(displayname=*));ADsPath;Subtree"

              Set objRecordSet = objCommand.Execute

              Do Until objRecordset.EOF
              strADsPath = objRecordset.Fields("ADsPath")
              Set objUser = GetObject(strADsPath)
              vcn = objUser.get ("cn")
              vFullName = objUser.get ("displayName")
              vlDAPPath = "cn=" & vcn & ",ou=test,dc=mydomain,dc=co,dc=uk"
              REM objUser.Put "cn", vFullName
              objUser.SetInfo

              set cont = GetObject("LDAP://ou=test,dc=mydomain,dc=co,dc=uk")
              set usr = cont.MoveHere("LDAP://" & vlDAPPath, "cn=" & vFullName)

              objRecordSet.MoveNext


              Loop

              objConnection.Close

              -----------------------------------------------------------

              Cheers
              Topper
              * Shamelessly mentioning "Don't forget to add reputation!"

              Comment


              • #8
                Topper,

                Cheers mate - worked a treat.

                Thanks for all your effort and hardwork

                Michael
                Michael Armstrong
                www.m80arm.co.uk
                MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

                ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

                Comment

                Working...
                X