NetDocuments-Archive / ad-join-cookbook

Chef cookbook to join windows computer to AD
Apache License 2.0
14 stars 12 forks source link

Error when joining into "Computers" CN #18

Closed cgulliver closed 6 years ago

cgulliver commented 7 years ago

This could be expected behavior but when testing in a sandbox, I get the following error "The system cannot find the file specified." I am attempting to join into the default "Computers" CN in the root so there is nothing to feed the OU property.

spuder commented 7 years ago

I've never tested that. The cookbook runs this powershell command

      Add-computer -DomainName #{domain} #{ou.nil? ? '' : '-OUPath "' + ou + '"'} #{server.nil? ? '' : '-Server "' + server + '"'} -Credential $credential -force -Options JoinWithNewName,AccountCreate -PassThru

if ou = nil, it should skip the -OUPath section. Are you omitting the ou property? It is optional, so try leaving it out completely.

cgulliver commented 7 years ago

Yes, I tried to omit the OU property completely and also pass as an empty parameter with no luck. I don't think anyone joins machines to the Computers CN so its not a big deal.

derekgroh commented 7 years ago

Quick fix could be to set it as the default in the resource.

property :ou, [String, NilClass], required: false, default: 'cn=computers'

vinyar commented 7 years ago

Yup @derekgroh , or alternatively you could use defined?(ou) instead of ou.nil?

mattlqx commented 7 years ago

Had the same problem but this works for me:

  domain_join domain do
    domain domain
    domain_user join_user
    domain_password join_pass
    ou nil
    action :join
  end
spuder commented 6 years ago

Closing If you have additional information, feel free to reopen.