Re: Can' get LDAP to work in WorkGrp



I don't think you'll ever be able to get that to function in a workgroup. The AD provider is looking for a domain controller but your workgroup machine isn't configured to use one. You might be able to use a direct LDAP connection to a specific domain controller, possibly passing alternate credentials as well, but the script will look different than what you have here.

--
Jeffery Hicks
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org

Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.
"maverick" <maverick@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:04BA0383-16E8-43ED-987E-4B5295D1C49C@xxxxxxxxxxxxxxxx
Hi,

I tried running the script appended below which runs fine on a machine
joined to a domain.
How can i get this script to run from a machine which is not joined to the
domain(xyz.mc.uk)?

I get the following error on the client which is not joined to the domain?

Windows Script Host
---------------------------
Script: C:\Documents and Settings\Administrator\Desktop\Search.vbs
Line: 21
Char: 1
Error: Table does not exist.
Code: 80040E37
Source: Provider


Is there a way out to run this script from a machine which is not in the
domain?



Script

strUserName = "1234567"
strLDAP = "<LDAP://dc=xyz,dc=mc,dc=ck>"
dtStart = TimeValue(Now())

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"

objConnection.Properties("User ID") = "xyz.mc.ck\user"
objConnection.Properties("Password") = "Pwd0334"
objConnection.Properties("Encrypt Password") = TRUE
objConnection.Properties("ADSI FLAG") = 1

objConnection.Open "Active Directory Provider"
set objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
strLDAP & ";(&(objectCategory=User)" & _
"(mobile=" & strUserName &
"));distinguishedName,mobile,sAmAccountName,cn;subtree"

Set objRecordSet = objCommand.Execute

If objRecordset.RecordCount = 0 Then
WScript.Echo "sAMAccountName: " & strUserName & " does not exist."
Else
WScript.Echo objRecordSet.fields("distinguishedName").value &" exists."
DNAME = objRecordSet.fields("distinguishedName").value
set objUser = GetObject("LDAP://"; & DNAME )
wscript.echo "itworked"
objUser.Put "userPrincipalName", "mtself@xxxxxxxxx"
objuser.setInfo
End If

objConnection.Close



.



Relevant Pages

  • Re: Users last logon info from logon script
    ... >> This script shows the local computer time when the users log on. ... > ' Because the lastLogon attribute is not replicated, ... Then, for each Domain Controller, ADO is used to search the ... > Dim objRootDSE, strConfig, objConnection, objCommand, strQuery ...
    (microsoft.public.security)
  • Re: Display All Locked Accounts in an OU
    ... > I have this script below I used from its source ... > particular OU and its sub-ou's for locked out accounts. ... you need only look at one domain controller. ... > Dim objRootDSE, strConfig, objConnection, objCommand, strQuery ...
    (microsoft.public.windows.server.scripting)
  • List users not logged onto domain for over X number of days
    ... I found a great script by ... ' Because the lastLogon attribute is not replicated, ... Then, for each Domain Controller, ADO is used to search the ... Dim strDNSDomain, objShell, lngBiasKey, lngBias, k, arrstrDCs ...
    (microsoft.public.windows.server.scripting)
  • Can someone help modify this VBScript
    ... how to modify this script to fit my needs. ... ' Because the lastLogon attribute is not replicated, ... Then, for each Domain Controller, ADO is used to search the ... Dim strDNSDomain, objShell, lngBiasKey, lngBias, k, arrstrDCs ...
    (microsoft.public.scripting.vbscript)
  • Re: garbage computer accounts
    ... that is why I use this great script. ... ' Controller in the domain must be queried to find the latest LastLogon ... Then, for each Domain Controller, ADO is used to search the ... Dim strDNSDomain, objShell, lngBiasKey, lngBias, k, arrstrDCs ...
    (microsoft.public.scripting.wsh)