Re: Can' get LDAP to work in WorkGrp
- From: "Jeffery Hicks [MVP]" <jhicks@xxxxxxxxxx>
- Date: Tue, 20 Nov 2007 16:38:49 -0500
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
.
- Follow-Ups:
- Re: Can' get LDAP to work in WorkGrp
- From: Tom
- Re: Can' get LDAP to work in WorkGrp
- References:
- Can' get LDAP to work in WorkGrp
- From: maverick
- Can' get LDAP to work in WorkGrp
- Prev by Date: Can' get LDAP to work in WorkGrp
- Next by Date: Re: How do I write to Excel
- Previous by thread: Can' get LDAP to work in WorkGrp
- Next by thread: Re: Can' get LDAP to work in WorkGrp
- Index(es):
Relevant Pages
|