Hi,

I found the below script which allows me to import Users into AD from an
Excel file:

http://www.rlmueller.net/CreateUsers.htm (about the VBScript)
http://www.rlmueller.net/Programs/CreateUsers.txt (the code)

I've managed to get this working so it creates a User in my domain, but I
need to alter this so it creates a Contact instead. Can anyone tell me how
to do this? My knowledge of scripting is VERY basic so the more detail you
can give me the better.

Thank you,

Curtis.

====================================
When replying by email please remove the X
====================================

Re: Altering an Add User script to Add Contact script for Active Directory import by Richard

Richard
Wed Dec 01 11:58:44 CST 2004

Curtis Fray wrote:

> I found the below script which allows me to import Users into AD from an
> Excel file:
>
> http://www.rlmueller.net/CreateUsers.htm (about the VBScript)
> http://www.rlmueller.net/Programs/CreateUsers.txt (the code)
>
> I've managed to get this working so it creates a User in my domain, but I
> need to alter this so it creates a Contact instead. Can anyone tell me how
> to do this? My knowledge of scripting is VERY basic so the more detail you
> can give me the better.

Hi,

The Create method of the container object is used to create objects in the
container (or OU). It takes two parameters, the class of the object and the
Relative Distinguished Name (RDN) of the new object in the container (the
"Common Name" for most classes of objects). To create a user (where strCN
has been assigned the value of the new Common Name):

Set objUser = objContainer.Create("user", "cn=" & strCN)

To create a contact, simply specify class "contact". For example:

Set objUser = objContainer.Create("contact", "cn=" & strCN)

Cautions: A contact is not a security principal (you cannot logon with as a
contact). The object does not have attributes such as: sAMAccountName,
userPrincipalName, homeDrive, homeDirectory, scriptPath, profilePath. Also,
the SetPassword method does not apply. However, contacts can be members of
groups. And, you can assign attributes like sn, givenName, initials. All
address and phone number attributes are available. Finally, since there is
not a userAccountControl attribute, the AccountDisabled method also does not
apply.

With the above in mind, I have used code very similar to the CreateUsers.vbs
referenced above to create contacts from a spreadsheet.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--



Re: Altering an Add User script to Add Contact script for Active Directory import by Curtis

Curtis
Thu Dec 02 03:05:52 CST 2004

Hi,

Thanks for the input. I have tried changing the specified class from "user"
to "contact" but unfortunately it fails. I just get an error saying "Unable
to create user with NT name: xxx". If I change it back to "user" it creates
xxx as a User without any errors.

One other thing I just realised, I will have to also be able to add their
email address (is that the "proxyAddresses" attribute?) from the Excel
spreadsheet too. Can the code be easily changed to accomodate this?

If anyone already has any code that does what I'm trying to accomplish,
please post it here! I basically just need to import a (huge) list of names
as contacts into AD. These just need the bare minimum info - First name,
Last name, Display name, E-mail.

Thanks again.

Regards,

Curtis.


"Richard Mueller [MVP]" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in
message news:%23odSJ%2381EHA.2292@TK2MSFTNGP15.phx.gbl...
>
> Hi,
>
> The Create method of the container object is used to create objects in the
> container (or OU). It takes two parameters, the class of the object and
> the
> Relative Distinguished Name (RDN) of the new object in the container (the
> "Common Name" for most classes of objects). To create a user (where strCN
> has been assigned the value of the new Common Name):
>
> Set objUser = objContainer.Create("user", "cn=" & strCN)
>
> To create a contact, simply specify class "contact". For example:
>
> Set objUser = objContainer.Create("contact", "cn=" & strCN)
>
> Cautions: A contact is not a security principal (you cannot logon with as
> a
> contact). The object does not have attributes such as: sAMAccountName,
> userPrincipalName, homeDrive, homeDirectory, scriptPath, profilePath.
> Also,
> the SetPassword method does not apply. However, contacts can be members of
> groups. And, you can assign attributes like sn, givenName, initials. All
> address and phone number attributes are available. Finally, since there is
> not a userAccountControl attribute, the AccountDisabled method also does
> not
> apply.
>
> With the above in mind, I have used code very similar to the
> CreateUsers.vbs
> referenced above to create contacts from a spreadsheet.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site - http://www.rlmueller.net
> --
>
>