Results 1 to 2 of 2

Thread: Updating Active Directory with ADO

  1. #1
    Join Date
    Aug 2003
    London, UK

    Updating Active Directory with ADO

    Have anybody ever updated user-data in active directory using ADO? I have the following code
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Provider = "ADsDSOObject"
    Set objRootDSE = GetObject("LDAP://RootDSE")
    strDomain = objRootDSE.Get("DefaultNamingContext")
    objConn.Properties("ADSI Flag") = 1
    objConn.Properties("User ID") = "internal\ADuser"
    objConn.Properties("Password") = "somepassword"
    objConn.Properties("Encrypt Password") = True
    objConn.Open "Active Directory Provider"
    Set objCommand = CreateObject("ADODB.Command")
    Set objCommand.ActiveConnection = objConn
    strCommandText = "<LDAP://OU=MYCOMPANYNAME," & strDomain  & ">;(samAccountName=mylogonaccountname);Title,samAccountName,Company,department,facsimileTelephoneNumber,Displayname,mobile,physicalDeliveryOfficeName,PostalAddress,postalCode,telephoneNumber,mail,homephone;subtree"
    objCommand.CommandText = strCommandText
    set objRS = Server.CreateObject("ADODB.recordset")
    objRS.LockType = 4             'adLockPessimistic
    objRS.Open strCommandText, objConn
    This code works fine but what I need to do is to update the information. So when I add
    objRS("DisplayName") = "Lumbago is a dumba$$"
    I get the following error message:
    Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.

    All help is appreciated! I have worked on this for more than 6 hours now and I hope someone canhelp...
    "Real programmers don't document, if it was hard to write it should be hard to understand"

  2. #2
    Join Date
    Jun 2003
    Indiana, USA
    Make sure the AD user you are using has administrative privlidges. What I mean by this is that you should be able to at least add when you are logged into your computer browsing the AD structure.
    Some things Man was never meant to know. For everything else, there's Google.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center