Showing posts with label Technet. Show all posts
Showing posts with label Technet. Show all posts

Monday, 2 October 2017

ActiveDirectory with VBA Part 4 - ADSI Edit

So in Part 1 I installed Active Directory Lightweight Directory Services (AD LDS) and in Part 2 worked through a Technet tutorial to create an AD LDS instance, also in Part 3. I showed how to uninstall an instance to wipe the slate clean. I gave some code that connected to the AD LDS instance a the bottom of Part 2.

Next I proceed with the subsequent Technet tutorial as it creates users and groups with some Active Directory administrative tools.

So launching ADSI Edit you get a MMC looking welcome screen with no connections...

Following the tutorial for connecting the finished dialog box looks like this...

Once connected the left explorer pane should have a new AD LDS Demo icon which can be double-clicked for expansion...

Double clicking on 'O=Microsoft,c' shows the application directory partition...

Carrying onto the next Technet tutorial in series about creating users and groups. After this tutorial some new objects have been created reflected in this screenshot.

When finished the following VBA code should be able to reach, query and find each object mentioned in the tutorial. This will help setup test data for more involved user and group logic.


Option Explicit

Sub Test()

    Dim oDirectoryService As Object
    Set oDirectoryService = _
        GetObject("LDAP://localhost:389/o=Microsoft,c=US")
    Debug.Assert TypeName(oDirectoryService) = "Object"

    Dim oOU_AD_LDS_Users As Object
    Set oOU_AD_LDS_Users = GetObject( _
        "LDAP://localhost:389/OU=AD LDS Users,o=Microsoft,c=US")
    Debug.Assert TypeName(oOU_AD_LDS_Users) = "Object"

    Dim oGroup_AD_LDS_Testers As Object
    Set oGroup_AD_LDS_Testers = GetObject( _
        "LDAP://localhost:389/CN=AD LDS Testers,OU=AD LDS Users,o=Microsoft,c=US")
    Debug.Assert TypeName(oGroup_AD_LDS_Testers) = "Object"

    Dim oUser_MaryNorth As Object
    Set oUser_MaryNorth = GetObject( _
        "LDAP://localhost:389/CN=Mary North,OU=AD LDS Users,o=Microsoft,c=US")
    Debug.Assert TypeName(oUser_MaryNorth) = "Object"


End Sub




ActiveDirectory with VBA Part 3 - Technet AD LDS Deleting an Instance

So I have been following the Technet tutorial Practice Working with AD LDS Instances and it assumes that you have a fresh install or the defaults in the wizard will be different. If you have been through the steps you might want to wipe the slate clean. In this part I show how to delete an Active Directory Lightweight Directory Services (AD LDS) instance.

In the Control Panel search box type "uninstall" this will yield search results including for Uninstall a program under the header of Program and Features

Clicking on Uninstall a program yields a list of software which is uninstallable.

Double click and follow a few 'are you sure' type messages.

ActiveDirectory with VBA Part 2 - Technet AD LDS Sample Instance

So following on from installing Active Directory Lightweight Directory Services (AD LDS) in Part 1 here I follow the Technet tutorial Practice Working with AD LDS Instances and I supply the screenshots as I go.

So we run the Active Directory Lightweight Directory Services Setup Wizard and I did do this by searching for it with the Windows 8 metro search box, after allowing permission I get the following welcome box

Clicking Next I get to next box and choose 'A unique instance'

For the instance name I accept the default as I am following the tutorial. If you are doing these twice then instance1 is taken, you may want to skip to Part 3 where I show how to delete an instance.

For the port numbers again things will be different if you have already run these steps once and already have an instance because each instance must listen on a different port. See Part 3 for how to delete an instance.

Because we're opening ports then you may get a firewall warning message like this so I select private networks only...

And again I am following the tutorial so I follow instructions, create an application directory partition and give the Partition name as in the tutorial as 'o=Microsoft,c=US'.

Next we accept the default file locations

Next use Nework service account as per tutorial

Then you will get a replication not available type warning box, click Yes to continue.

Then you get the AD LDS Administrators box, note I have airbrushed my details from this slide. Click the default value of Currently logged on user.

On the Importing LDIF Files. Select the following MS-InetOrgPerson.ldf, MS-User.ldf, MS-UserProxy.ldf, MS-UserProxyFull.ldf, MS-ADLDS-DisplaySpecifiers.ldf. NOT ALL OF THESE ARE IMMEDIATELY VISIBLE, YOU NEED TO SCROLL

Then you get a confirmation screen...

Then it does some work...

Then you get some success splash screen.

Now you can write some code to connect to this new AD LDS instance. This should work if you went wrong you'll need to use Part 3 to delete instance and try again


Option Explicit

Sub Test()

    Dim oDirectoryService As Object
    Set oDirectoryService = GetObject("LDAP://localhost:389/o=Microsoft,c=US")
    Debug.Assert TypeName(oDirectoryService) = "Object"

End Sub