Join AD group script
Hello all,
I just started using the K appliances and so far so good. Right now I'm at a loss. I have no issues pulling/deploying images, but now comes the fun part. I was able to join the domain, using one of the pre-installed post scripts available to me. But in our environment, we must be able to not only join the domain, but move the computer to the correct OU and make sure the computer is receiving the correct name in order not to cause any conflicts. Any help would be appreciated.
Thank you
I just started using the K appliances and so far so good. Right now I'm at a loss. I have no issues pulling/deploying images, but now comes the fun part. I was able to join the domain, using one of the pre-installed post scripts available to me. But in our environment, we must be able to not only join the domain, but move the computer to the correct OU and make sure the computer is receiving the correct name in order not to cause any conflicts. Any help would be appreciated.
Thank you
0 Comments
[ + ] Show comments
Answers (6)
Please log in to answer
Posted by:
dyehardfan
13 years ago
This is the script that came pre-installed on my K2, it looks like it should have the functionality you need.
#!/bin/bash
### You must edit these for your specific environment
# 1) fully qualified DNS name of Active Directory Domain.
domain="test.example.com"
# 2) username of a privileged network user.
udn=""
# 3) password of a privileged network user.
password=""
# 4) Distinguished name of container for the computer
ou="ou=Computers,ou=lab,DC=test,DC=example,DC=com"
# 5) 'enable' or 'disable' automatic multi-domain authentication
alldomains="enable"
### End of configuration
# Get the local computer's name.
computerid=`/usr/sbin/scutil --get LocalHostName`
# Activate the AD plugin, just to be sure
defaults write /Library/Preferences/DirectoryService/DirectoryService "Active Directory" "Active"
plutil -convert xml1 /Library/Preferences/DirectoryService/DirectoryService.plist
# Bind to AD
dsconfigad -f -a $computerid -domain $domain -u "$udn" -p "$password" -ou "$ou"
dsconfigad -alldomains $alldomains
# Add the AD node to the search path
if [ "$alldomains" = "enable" ]; then
csp="/Active Directory/All Domains"
else
csp="/Active Directory/$domain"
fi
dscl /Search -append / CSPSearchPath "$csp"
dscl /Search -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath
dscl /Search/Contacts -append / CSPSearchPath "$csp"
dscl /Search/Contacts -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath
# Restart Directory Service
killall DirectoryService
sleep 2
exit 0
Posted by:
dchristian
13 years ago
jguitierrez,
This is what i have been using to move computers to specific OUs.
I have a little VBS that checks a text file.
The text file has the computer name prefixes then a "|" and finally the OU the computer should be moved to.
Example text file. Must be named "inputer.txt"
I think all you'll need to do is adjust this line to point to your domain.
Hope this helps
This is what i have been using to move computers to specific OUs.
I have a little VBS that checks a text file.
The text file has the computer name prefixes then a "|" and finally the OU the computer should be moved to.
Option Explicit
Dim criteria
Dim newOU
Dim compName
Const SearchBaseDN="DC=mydomain,DC=com"
Const defualtComputerOU = "CN=Computers"
compName = GetComputerName()
criteria=GetComputerNamePrefix()
newOU=FindValue(UCase(criteria))
If (newOU <> "") Then
MoveComputer SearchBaseDN,defualtComputerOU,newOU,compName
Else
WScript.Echo "no path found"
End if
Function GetComputerName()
Dim objNTInfo
Set objNTInfo = CreateObject("WinNTSystemInfo")
GetComputerName= objNTInfo.ComputerName
End Function
Function GetComputerNamePrefix()
Dim objNTInfo
Dim xname
Const delimeter = "-"
Set objNTInfo = CreateObject("WinNTSystemInfo")
xname = objNTInfo.ComputerName
If(InStr(xname,delimeter)> 0) Then
GetComputerNamePrefix=Left(xname,InStr(xname,delimeter)-1)
Else
GetComputerNamePrefix = xname
End If
End function
Function FindValue(xFindValue)
Dim objFSO
Dim objTextFile
Dim strNextLine
Dim arrServiceList
Dim i
Dim oDic
Set oDic = CreateObject("scripting.dictionary")
Const InputFile = "inputer.txt"
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
(InputFile, ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , "|")
oDic.Add arrServiceList(0),arrServiceList(1)
Loop
FindValue = oDic.Item(xFindValue)
End Function
Sub MoveComputer(xSearchBase,xdefualtComputerOU,xnewOU,xCompName)
Dim baseOU
Dim newDest
Dim objNewOU
Dim objMoveComputer
baseOU = "LDAP://CN=" & xCompName & "," & xdefualtComputerOU & "," & xSearchBase
newDest = "LDAP://" & xnewOU
WScript.Echo baseOU
WScript.Echo newDest
Set objNewOU = GetObject(newDest)
Set objMoveComputer = objNewOU.MoveHere _
(baseOU, "CN=" & xcompName)
End Sub
Example text file. Must be named "inputer.txt"
THE|OU=Computers,OU=Test Enviroment,DC=mydomain,DC=com
VANT|OU=Computers,OU=IT Department,DC=mydomain,DC=com
I think all you'll need to do is adjust this line to point to your domain.
Const SearchBaseDN="DC=mydomain,DC=com"
Hope this helps
Posted by:
jgutierrez
13 years ago
ORIGINAL: dyehardfan
This is the script that came pre-installed on my K2, it looks like it should have the functionality you need.
#!/bin/bash
### You must edit these for your specific environment
# 1) fully qualified DNS name of Active Directory Domain.
domain="test.example.com"
# 2) username of a privileged network user.
udn=""
# 3) password of a privileged network user.
password=""
# 4) Distinguished name of container for the computer
ou="ou=Computers,ou=lab,DC=test,DC=example,DC=com"
# 5) 'enable' or 'disable' automatic multi-domain authentication
alldomains="enable"
### End of configuration
# Get the local computer's name.
computerid=`/usr/sbin/scutil --get LocalHostName`
# Activate the AD plugin, just to be sure
defaults write /Library/Preferences/DirectoryService/DirectoryService "Active Directory" "Active"
plutil -convert xml1 /Library/Preferences/DirectoryService/DirectoryService.plist
# Bind to AD
dsconfigad -f -a $computerid -domain $domain -u "$udn" -p "$password" -ou "$ou"
dsconfigad -alldomains $alldomains
# Add the AD node to the search path
if [ "$alldomains" = "enable" ]; then
csp="/Active Directory/All Domains"
else
csp="/Active Directory/$domain"
fi
dscl /Search -append / CSPSearchPath "$csp"
dscl /Search -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath
dscl /Search/Contacts -append / CSPSearchPath "$csp"
dscl /Search/Contacts -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath
# Restart Directory Service
killall DirectoryService
sleep 2
exit 0
I should have mentioned this earlier. I tried this one and no dice. But thanks
Posted by:
jgutierrez
13 years ago
I'll give this a shot.
Thanks
Thanks
ORIGINAL: dchristian
jguitierrez,
This is what i have been using to move computers to specific OUs.
I have a little VBS that checks a text file.
The text file has the computer name prefixes then a "|" and finally the OU the computer should be moved to.
Option Explicit
Dim criteria
Dim newOU
Dim compName
Const SearchBaseDN="DC=mydomain,DC=com"
Const defualtComputerOU = "CN=Computers"
compName = GetComputerName()
criteria=GetComputerNamePrefix()
newOU=FindValue(UCase(criteria))
If (newOU <> "") Then
MoveComputer SearchBaseDN,defualtComputerOU,newOU,compName
Else
WScript.Echo "no path found"
End if
Function GetComputerName()
Dim objNTInfo
Set objNTInfo = CreateObject("WinNTSystemInfo")
GetComputerName= objNTInfo.ComputerName
End Function
Function GetComputerNamePrefix()
Dim objNTInfo
Dim xname
Const delimeter = "-"
Set objNTInfo = CreateObject("WinNTSystemInfo")
xname = objNTInfo.ComputerName
If(InStr(xname,delimeter)> 0) Then
GetComputerNamePrefix=Left(xname,InStr(xname,delimeter)-1)
Else
GetComputerNamePrefix = xname
End If
End function
Function FindValue(xFindValue)
Dim objFSO
Dim objTextFile
Dim strNextLine
Dim arrServiceList
Dim i
Dim oDic
Set oDic = CreateObject("scripting.dictionary")
Const InputFile = "inputer.txt"
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
(InputFile, ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , "|")
oDic.Add arrServiceList(0),arrServiceList(1)
Loop
FindValue = oDic.Item(xFindValue)
End Function
Sub MoveComputer(xSearchBase,xdefualtComputerOU,xnewOU,xCompName)
Dim baseOU
Dim newDest
Dim objNewOU
Dim objMoveComputer
baseOU = "LDAP://CN=" & xCompName & "," & xdefualtComputerOU & "," & xSearchBase
newDest = "LDAP://" & xnewOU
WScript.Echo baseOU
WScript.Echo newDest
Set objNewOU = GetObject(newDest)
Set objMoveComputer = objNewOU.MoveHere _
(baseOU, "CN=" & xcompName)
End Sub
Example text file. Must be named "inputer.txt"
THE|OU=Computers,OU=Test Enviroment,DC=mydomain,DC=com
VANT|OU=Computers,OU=IT Department,DC=mydomain,DC=com
I think all you'll need to do is adjust this line to point to your domain.
Const SearchBaseDN="DC=mydomain,DC=com"
Hope this helps
Posted by:
jgutierrez
13 years ago
Posted by:
dchristian
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.