function userExists ([string]$name)
In my view this function should use a domain parameter to work properly.
Comments: ** Comment from web user: KevinColeMCM **
I also had this issue where the server was on DOMAINA and user accounts were on DOMAINB
The option I used instead however was to create an entry in the autospinstallerconfig.xml and modify the functions so that an LDAP path is passed into the user exists method if it is provided in the config file.
Updated userExists function to accept ldap option for override:
```
# ====================================================================================
# Func: userExists
# Desc: "Here is a little powershell function I made to see check if specific active directory users exists or not."
# From: http://oyvindnilsen.com/powershell-function-to-check-if-active-directory-users-exists/
# ====================================================================================
function userExists ([string]$name, [string]$ldap)
{
#written by: Øyvind Nilsen (oyvindnilsen.com)
[bool]$ret = $false #return variable
$domainRoot = [ADSI]"$ldap"
$dirSearcher = New-Object System.DirectoryServices.DirectorySearcher($domainRoot)
$dirSearcher.filter = "(&(objectClass=user)(sAMAccountName=$name))"
$results = $dirSearcher.findall()
if ($results.Count -gt 0) #if a user object is found, that means the user exists.
{
$ret = $true
}
return $ret
}
```
Updated foreach block in AutoSPInstallerFunctions.ps1 :: ValidateCredentials
```
foreach ($account in $accountsToCheck)
{
$domain,$accountName = $account -split "\\"
Write-Host -ForegroundColor White " - Account `"$account`"..." -NoNewline
if (!(userExists $accountName -ldap $xmlinput.Configuration.Farm.CustomLdap))
{
Write-Host -BackgroundColor Red -ForegroundColor Black "Invalid!"
$acctInvalid = $true
}
else
{
Write-Host -ForegroundColor Black -BackgroundColor Green "Verified."
}
}
```
Added under <Farm> element into config xml:
```
<Configuration Environment="PILOT" Version="3.99.60">
<Farm>
<CustomLdap>LDAP://DC=LAN,DC=local</CustomLdap>
</Farm>
</Configuration>
```