# VBForums CodeBank > CodeBank - Other >  Create User in Active Directory

## RobDog888

You can create a new user in Active Directory with this code.

VB Code:
Dim adObj As Object
Dim adUser As Object
Set adObj = GetObject("WinNT://Domain")
Set adUser = adObj.Create("user", "RobDog888")
adUser.SetInfo
Set adUser = Nothing
Set adObj = Nothing

----------


## ankeet1

RobDog,
you are like my savior! Hey, i did find a script to get 'User Name' from AD, but how to get User ID from AD? (Windows 2003 Server). This question is for Classic VB6.0.

Ankeet

----------


## cjwallace

Hi guys. 

This code fails if Option Strict is switched on.

Any ideas on how to change this so it works with option strict

Cheers

----------


## RobDog888

This code works for VB 6 but could be converted for .net use.

Give me a minute.

----------


## cjwallace

Thanks mate look forward to seeing the code.

Thanks again

----------


## cjwallace

Hi mate did you ever get around to moving this over to vb.2005?

----------


## RobDog888

No I havent as my server has been down for a while now (hardware parts need replacing) so I dont have a system running AD to test on.

----------

