Note that there are some explanatory texts on larger screens.

plurals
  1. PORefactoring LDAP/AD script from VBS to C#
    primarykey
    data
    text
    <p>I need to refactor a VBS dealing with LDAP, ADODB and ActiveDirectory from VBS to C#. The part I'm stuck is connecting (just starting and already stuck... great). This is the original source</p> <pre><code>Set objRootDSE = GetObject("LDAP://RootDSE") strConfig = objRootDSE.Get("configurationNamingContext") strDNSDomain = objRootDSE.Get("defaultNamingContext") Set adoCommand = CreateObject("ADODB.Command") Set adoConnection = CreateObject("ADODB.Connection") adoConnection.Provider = "ADsDSOObject" adoConnection.Open "Active Directory Provider" adoCommand.ActiveConnection = adoConnection strQuery = "&lt;LDAP://dm1.com.local/OU=CN,OU=Users,OU=CMS Organizational,OU=CMS_Users_and_Groups,DC=cms,DC=local&gt;;(&amp;(objectCategory=person)(objectClass=user)(!useraccountcontrol:1.2.840.113556.1.4.803:=2));distinguishedName,lastLogon,whenCreated;subtree" adoCommand.CommandText = strQuery adoCommand.Properties("Page Size") = 100 adoCommand.Properties("Timeout") = 60 adoCommand.Properties("Cache Results") = False Set adoRecordset = adoCommand.Execute </code></pre> <p>And the C# looks like this</p> <pre><code>DirectoryEntry dse = new DirectoryEntry("LDAP://RootDSE"); string config = dse.Properties["configurationNamingContext"].Value.ToString(); string domain = dse.Properties["defaultNamingContext"].Value.ToString(); Connection connection = new Connection(); connection.Provider = "ADsDSOObject"; connection.Open("ADsDSOObject", "", "", 0); object records, parameters = ""; ADODB.Command command = new Command(); command.ActiveConnection = connection; command.CommandText = "&lt;LDAP://dm1.com.local/OU=CN,OU=Users,OU=CMS Organizational,OU=CMS_Users_and_Groups,DC=cms,DC=local&gt;;(&amp;(objectCategory=person)(objectClass=user)(!useraccountcontrol:1.2.840.113556.1.4.803:=2));distinguishedName,lastLogon,whenCreated;subtree"; command.Execute(out records, ref parameters, 0); </code></pre> <p>It gives me the error</p> <pre><code>Interface not supported (Provider) at ADODB.CommandClass.Execute(Object&amp; RecordsAffected, Object&amp; Parameters, Int32 Options) at Adug.Program.Main(String[] args) in E:\...\Program.cs:line 66 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload