myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


LDAP Authentication

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> VB Script >> LDAP Authentication Page: [1]
Login
Message << Older Topic   Newer Topic >>
LDAP Authentication - 6/30/2008 3:10:57 PM   
jfattizzi

 

Posts: 88
Score: 0
Joined: 3/5/2004
Status: offline
Hello all.  I have a script that runs during a new build and is launched under a local account on the domain.  The local account has access to domain resources, but it is not authenticated to the domain.

My script simply moves a computer account into a global group using alternate credentials.  The alt credentials has the access to do the actual move.  The problem I am having is the script fails because the user it is running under isnt authenticated to the domain.  If I run it as a domain user, then it works like a charm.  How can I authenticate as a domain account inside the script so that during build time this works?

Here is my script:

Const ADS_SCOPE_SUBTREE = 2
Const ADS_PROPERTY_APPEND = 3

Set oShell = WScript.CreateObject("WScript.Shell")
Wscript.Echo (Date() & " " & Time() & ": Script to move workstation to Active Directory Group")

sComputer = oShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
 sLocation = oShell.ExpandEnvironmentStrings("%PCLOCCODE%")
 sGroup = "GPO_DevExclude"
 
 ' handle null values
 If sComputer = "" Then sComputer = "UNDEFINED"
 If IsNull(sComputer) Then sComputer = "UNDEFINED"
 If IsEmpty(sComputer) Then sComputer = "UNDEFINED"
 
 If sLocation = "" Then sLocation = "UNDEFINED"
 If IsNull(sLocation) Then sLocation = "UNDEFINED"
 If IsEmpty(sLocation) Then sLocation = "UNDEFINED"
 
Wscript.Echo (Date() & " " & Time() & ": Computer Name is defined as: " & sComputer)
Wscript.Echo (Date() & " " & Time() & ": PCLOCCODE is defined as: " & sLocation)

If sComputer = "UNDEFINED" Then
 Wscript.Echo (Date() & " " & Time() & ": Computer Name is UNDEFINED, cannot continue")
End If

Select Case sLocation
 
    Case "CTS"
     sLDAP = "
LDAP://DC=ac-eut,DC=lp-eut,DC=acml,DC=com"
     sUsername = "cn=administrator,ou=Users,DC=ac-eut,DC=lp-eut,DC=acml,DC=com"
  sPassword = ""
     sGroupDN = "
LDAP://ac-eut.lp-eut.acml.com/cn=" & sGroup & ",OU=Groups,OU=Workstations,DC=ac-eut,DC=lp-eut,DC=acml,DC=com"
     Wscript.Echo (Date() & " " & Time() & ": CTS location code has been identified")
                
    Case "QALAB"
     sLDAP = "
LDAP://DC=ac-qa,DC=lp-qa,DC=acml,DC=com"
     sUsername = "cn=acbuilder,ou=Svcacct,OU=Enterprise,DC=ac-qa,DC=lp-qa,DC=acml,DC=com"
  sPassword = ""
     sGroupDN = "
LDAP://ac.lp.acml.com/cn=" & sGroup & ",OU=Groups,OU=Workstations,DC=ac-qa,DC=lp-qa,DC=acml,DC=com"
     Wscript.Echo (Date() & " " & Time() & ": QALAB location code has been identified")    
     
    Case Else ' Production
     sLDAP = "
LDAP://DC=ac,DC=lp,DC=acml,DC=com"
     sUsername = "cn=acbuilder,ou=Svcacct,OU=Enterprise,DC=ac,DC=lp,DC=acml,DC=com"
     sPassword = ""
     sGroupDN = "
LDAP://ac.lp.acml.com/cn=" & sGroup & ",OU=Groups,OU=Workstations,DC=ac,DC=lp,DC=acml,DC=com"
     Wscript.Echo (Date() & " " & Time() & ": PROD location code has been identified")    

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

 objConnection.Properties("ADSI Flag") = 3
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("SearchScope") = ADS_SCOPE_SUBTREE

 ' Query AD to see where comptuer account is located
objCommand.CommandText = "SELECT ADsPath FROM '" & sLDAP & "' WHERE objectCategory='computer' " & "AND name='" & sComputer & "';subtree"
 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
strADSPath =  objRecordSet.Fields("ADsPath").Value

'Remove the leading LDAP://
strADSPath = Mid(strADSPath,8)
 
Set objNamespaceLDAP = GetObject("LDAP:")
Set objMyComp = objNamespaceLDAP.OpenDSObject(sGroupDN, sUsername,sPassword, 0)
objMyComp.putEx ADS_PROPERTY_APPEND, "member", Array(strADSPath)
objMycomp.setinfo

Wscript.Echo (Date() & " " & Time() & ": Finished running script, returning control to parent script")
Post #: 1
RE: LDAP Authentication - 6/30/2008 3:51:05 PM   
akaplan


Posts: 172
Score: 21
Joined: 4/22/2003
From: North Carolina
Status: offline
Did you try ADS_SECURE_AUTHENTICATION?  That would put your openDSObject to parameter to 1 instead of 0.

Alan


(in reply to jfattizzi)
Post #: 2
RE: LDAP Authentication - 6/30/2008 3:58:55 PM   
jsandys


Posts: 464
Score: 17
Joined: 3/24/2005
From: San Antonio, TX
Status: offline
Can you provide some clarification on the account that you are using please. There are few statements that are seemingly contradictory in your description.

"local account on the domain" ... "but it is not authenticated to the domain" is contradictory.
"domain user" is a "local domain account"

Is the account a domain account or a local system account? If so, what groups is it a member of? Does the account have a password? How does the account have access to domain resources?

_____________________________

Jason
________________________________________
http://myitforum.com/cs2/blogs/jsandys/default.aspx

(in reply to jfattizzi)
Post #: 3
RE: LDAP Authentication - 6/30/2008 5:48:52 PM   
rbennett806


Posts: 786
Score: 13
Joined: 6/14/2006
Status: offline
Also, is the machine that you're running the script from bound to the domain?

And does the sample VBScript code in this post help you at all: http://www.myitforum.com/forums/How_to_query_AD_from_WinPE_2%250/m_150401/tm.htm ?

(in reply to jsandys)
Post #: 4
RE: LDAP Authentication - 7/1/2008 10:50:20 AM   
jfattizzi

 

Posts: 88
Score: 0
Joined: 3/5/2004
Status: offline
Sorry, I will try to clarify.  The machine is bound to the domain, but the user is a local user account with a password. 

(in reply to rbennett806)
Post #: 5
RE: LDAP Authentication - 7/3/2008 11:10:26 AM   
jsandys


Posts: 464
Score: 17
Joined: 3/24/2005
From: San Antonio, TX
Status: offline
Then what you are trying to do is not possible.  A local account has no context within the domain and thus cannot authenticate to it.  You must use a domain account or an account that lives within a realm that is trusted by the domain -- there is no way for a domain to trust a local system SAM database.

It is possible to use the computer account for the system you are on if you launch the script in the context of the local system.  Why are you opposed to using a domain account?

_____________________________

Jason
________________________________________
http://myitforum.com/cs2/blogs/jsandys/default.aspx

(in reply to jfattizzi)
Post #: 6
Page:   [1]
All Forums >> [Scripting Technologies] >> VB Script >> LDAP Authentication Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.641