Re: Can' get LDAP to work in WorkGrp



Good to know.

Richard

"Jeffery Hicks [MVP]" <jhicks@xxxxxxxxxx> wrote in message
news:C8C25400-83C3-4047-90B3-5E4FCC11592E@xxxxxxxxxxxxxxxx
That's the first thing I thought to. But I tried using ADO with alternate
credentials and it from non-domain member as long as I specified a domain
controller in the LDAP string. I was a little surprised it worked.

--
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.
"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23p02V6HLIHA.4272@xxxxxxxxxxxxxxxxxxxxxxx
Alternate credentials with ADO requires that the client be joined to the
domain. You might have better luck using the OpenDSObject method. See
this link:

http://msdn2.microsoft.com/en-us/library/aa706065.aspx

You will need to specify a Domain Controller in the binding string. I
have not tried this, so I can't say if it will work.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"Jeffery Hicks [MVP]" <jhicks@xxxxxxxxxx> wrote in message
news:%23deaidHLIHA.536@xxxxxxxxxxxxxxxxxxxxxxx
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: Writing Script for ScanDisk and Defrag
    ... then create a computer startup script GPO to run it. ... determine if a defrag is needed. ... Microsoft PowerShell MVP ... Coming Soon: Windows PowerShell: TFM 2nd Ed. ...
    (microsoft.public.scripting.wsh)
  • Re: Writing Script for ScanDisk and Defrag
    ... *exactly* what is in the script you are scheduling, ... the scheduled task how can I get it to actually run them without needing ... Microsoft PowerShell MVP ... Coming Soon: Windows PowerShell: TFM 2nd Ed. ...
    (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)
  • Re: Writing Script for ScanDisk and Defrag
    ... You could make it part of a user's logon script, assuming their account has rights to run defrag. ... Coming Soon: Windows PowerShell: TFM 2nd Ed. ... > Microsoft PowerShell MVP ...
    (microsoft.public.scripting.wsh)
  • 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)