Re: Can' get LDAP to work in WorkGrp



It might work if you can specify a domain controller in your query:

"SELECT Name FROM 'LDAP://DC01/dc=testdomain,dc=local' WHERE objectCategory='user'"

--
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.
"Tom" <private@xxxxxxxxxxx> wrote in message news:A52DC59E-F027-4CF4-B5C7-3D7186583CED@xxxxxxxxxxxxxxxx
Hi,
I have a similar problem. I too wish to query active directory and am using
similar code to Maverick to do so (the piece with the connection details is
actually identical and the only real difference is I am running a different
query).
The machine I am using is a member of the domain being queried. If I log on
as a user from that domain I can run the script and it works fine. However,
if I log on to the same machine but as a user from a different domain and run
the script I get the exact same error message as Maverick.
Although I specifiy an account in the domain in my script it is as if Active
Directory is still using the credentials with which I logged on to decide
whether or not I should be granted access to.
Has anyone got any ideas?

Tom

"Jeffery Hicks [MVP]" wrote:

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: HELP! Need AD Query for Last login
    ... query the DCs in the USA domain, how would I modify the script? ... I'm new to VB script and making this simple modification is beyond me at ... >> ' Because the lastLogon attribute is not replicated, ... Then, for each Domain Controller, ADO is used to search the ...
    (microsoft.public.scripting.vbscript)
  • Re: HELP! Need AD Query for Last login
    ... You want to do this only for the second query that runs on each DC. ... > and how long the revised script took. ... >> ' Because the lastLogon attribute is not replicated, ... Then, for each Domain Controller, ADO is used to search the ...
    (microsoft.public.scripting.vbscript)
  • Re: HELP! Need AD Query for Last login
    ... You want to do this only for the second query that runs on each DC. ... If the original script ran to completion, I'd like to know how long it took, ... > ' Because the lastLogon attribute is not replicated, ... Then, for each Domain Controller, ADO is used to search the ...
    (microsoft.public.scripting.vbscript)
  • Re: Writing Script for ScanDisk and Defrag
    ... Microsoft PowerShell MVP ... But you might want your script to actually do more work to make sure it is not defragging and scanning too often. ... I would still recommend that you go back to square one and make sure that the *reason* for doing these things is well understood. ... That seems a small risk to me, however, as defrag is designed to avoid committing changes that would leave the file structure in an invalid intermediate state. ...
    (microsoft.public.scripting.wsh)
  • Re: Writing Script for ScanDisk and Defrag
    ... if %date:~7,2% equ 01 (defrag c:) ... Microsoft PowerShell MVP ... Coming Soon: Windows PowerShell: TFM 2nd Ed. ... then create a computer startup script GPO to run it. ...
    (microsoft.public.scripting.wsh)

Loading