Announcement

Collapse
No announcement yet.

Creating Exchange Users with Excel

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

  • Creating Exchange Users with Excel

    Sub CreateUsers()

    Dim Row As Integer
    Dim oMailbox As CDOEXM.IMailboxStore
    Dim oUser As IADsUser

    Set rootDSE = GetObject(LDAP://RootDSE)
    DomainContainer = rootDSE.Get("defaultNamingContext")
    Set oOU = GetObject(LDAP://OU=Test,DC=mycompany,DC=com)

    Row = 1
    Do Until Cells(Row, 1) = Empty
    gname = Trim(Cells(Row, 1).Value)
    sname = Trim(Cells(Row, 2).Value)
    ID = Cells(Row, 3).Value
    mailingaddress = Cells(Row, 4).Value
    city = Cells(Row, 5).Value
    postalcode = Cells(Row, 6).Value
    homephone = Cells(Row, 7).Value
    cellular = Cells(Row, 8 ).Value
    dept = Trim(Cells(Row, 9).Value)
    ounit = Trim (Cells(Row,10).Value)

    FullName = gname & " " & sname

    ...
    ...
    ...

    here how it looks like my excel file::

    fname lname ID mailingaddress city postalcode homephone cellular dept ounit
    ================================================== =====
    john tom 1 udef on l90212 udef udef design ounit1

    tom tom 2 udef to 323221 udef udef animation ounit2

    Set oOU = GetObject(LDAP://OU=Test,DC=mycompany,DC=com)

    howto modify the script instead of OU=Test to use a variable ??

    OU's ounit1 and ounit2 are already defined in DC.

  • #2
    Re: Creating Exchange Users with Excel

    I would build up a string so:

    Code:
    strObject = "LDAP://OU=" & trim(cells(Row,10).value) & ",DC=mycompany,DC=com"
    Set oOu = GetObject(strObject)
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

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

    Comment


    • #3
      Re: Creating Exchange Users with Excel

      very thanks !

      Comment

      Working...
      X