Administrator Username and Password RRS feed

  • Question

  • I am trying to update Active Directory in VBA/Excel by passing the Admin Username and Password to make the update

    VBA Code


    sQuery1 = "LDAP://OU=Software,OU=Groups,OU=blabla"

    Set objOU = GetObject(sQuery1)
    Set UAT = objOU.Create("group", "CN=UAT_" & sPkg)
    UAT.Put "grouptype", -2147483644
    UAT.Put "nvdPolicy", "+software/" & sPkg

    This works if you are running excel with Admin Privs but not as a regular user

    in C# there is a way to include the Admin Username and Password when creating the object in Active Directory

    DirectoryEntry entry = new DirectoryEntry("LDAP://" + ouPath);
    entry.Username = "whatever your admin username is";
    entry.Password = "whatever your admin password is";
    DirectoryEntry group = entry.Children.Add("CN=" + name, "group");
    group.Properties["sAmAccountName"].Value = name;
    group.Properties["groupType"].Value = -2147483644;
    group.Properties["nvdPolicy"].Value = "+software/" + name;

    Just wondering if there is a way to replicate what is in C# in VBA??

    Tuesday, December 19, 2017 6:50 PM