Announcement

Collapse
No announcement yet.

vb AD script display full name in ad

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

  • vb AD script display full name in ad

    i have a vb script that sets up new users accounts in AD. it is working great except for 1 small thing. when i use the script to setup an account and you go into the domain control or otherwise search AD it will display the UPN instead of the full name like it displays if i setup without a script. so if i setup John Smith manually and i seach AD it will bring up John Smith in the seach. but if i set him up with the script it will bring up JSmith. which is ok but i'de like it to display as the full name. is their something i have to set to do this.
    MCSE 2000\2003, A+
    00000001-00000011-00000011-00000111

  • #2
    Re: vb AD script display full name in ad

    Could you please attach the script ?
    My guess would be that you are not setting displayName attribute and it is auto-populated with the value of sAMAccountName attribute.
    Guy Teverovsky
    "Smith & Wesson - the original point and click interface"

    Comment


    • #3
      Re: vb AD script display full name in ad

      Maybe this will help.

      http://forums.petri.com/showthread.php?t=2747

      Topper helped me out a few months ago on this

      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
        Re: vb AD script display full name in ad

        its reading the names from a text file and setting them up.

        Const ADS_PROPERTY_APPEND = 3
        Set FSO = CreateObject("Scripting.FileSystemObject")

        Set NamesFile = FSO.OpenTextFile("names.txt", 1)
        fullname = "a"

        do until namesfile.AtEndOfStream
        FullName = NamesFile.ReadLine
        NamesList = Nameslist & ", " & fullName
        if fullname <> "" then
        Seperator = instr(fullname, " ")
        FirstName = left(Fullname, Seperator - 1)
        LastName = Mid(fullname, Seperator + 1, len(fullName) - (Seperator +1))
        userName = left(firstname,1) & lastname

        Set objOU = GetObject("LDAP://ou=Production,dc=domain,dc=local")

        'create user account
        Set objUser = objOU.Create("user", "cn=" & username)
        objUser.Put "sAMAccountName", username
        objuser.sn = LastName
        objuser.givenname = FirstName
        objuser.displayname = FirstName & " " & LastName
        objuser.userPrincipalName = UserName & "@domain.local"
        objuser.Description = "Contact Center Representative"
        objuser.SetInfo

        'stuff that has to be set after account created
        objuser.ChangePassword "", "password"
        objuser.AccountDisabled = FALSE
        objUser.Put "pwdLastSet", 0
        objuser.SetInfo

        'put in groups
        Set objGroup = GetObject _
        ("LDAP://cn=MD_Contact Center,dc=domain,dc=local")
        objGroup.PutEx ADS_PROPERTY_APPEND, _
        "member", Array("cn=" & username & ",ou=Production, dc=domain, dc=local")
        objGroup.SetInfo

        Set objGroup = GetObject _
        ("LDAP://cn=MD_Contact Center Printers,dc=domain,dc=local")
        objGroup.PutEx ADS_PROPERTY_APPEND, _
        "member", Array("cn=" & username & ",ou=Production, dc=domain, dc=local")
        objGroup.SetInfo

        end if

        loop
        NamesFile.close
        msgbox("The Following Users have been Set up" & nameslist)
        MCSE 2000\2003, A+
        00000001-00000011-00000011-00000111

        Comment


        • #5
          Re: vb AD script display full name in ad

          My bad. ADU&C uses CN attribute and not displayName.
          So, you will need to set CN attribute to the Full Name.
          Guy Teverovsky
          "Smith & Wesson - the original point and click interface"

          Comment


          • #6
            Re: vb AD script display full name in ad

            thanks that worked.
            MCSE 2000\2003, A+
            00000001-00000011-00000011-00000111

            Comment

            Working...
            X