Comments (6)
Hi,
we solved it with two tasks:
- name: "Search computer object in ad to fetch guid [ad_manage_computer_add]" microsoft.ad.object_info: ldap_filter: "(&(objectClass=computer)(cn={{ inventory_hostname_short }}*))" properties: '*' domain_server: ADCONTROLLER domain_username: ADMIN domain_password: PASSWORD delegate_to: ADCONTROLLER register: reg_computer_obj - name: "Move computer object to the right Active Directory OU [ad_manage_computer_add]" microsoft.ad.object: identity: "{{ reg_computer_obj.objects.0.ObjectGUID }}" name: "{{ inventory_hostname_short }}" path: "CN=Computers,DC=domain,DC=com" type: computer domain_server: ADCONTROLLER domain_username: ADMIN domain_password: PASSWORD state: present delegate_to: ADCONTROLLER
Hope that helps...
Thank you for posting this. That has got me thinking of a few ideas to test and I believe I have figured it out. Since identity is looking for a matching SamAccountName for the computer object, it must end with a $. I assumed that the code in ansible would append the $ to the end of the entry as every computer object in Active Directory must end in $ for it's SamAccountName. That appears not to be the case. After some trial and error along with the above inspiration, I have tested this solution to work. I also recommend the documentation be appended as well.
- name: Move server to Servers OU
microsoft.ad.object:
identity: "{{ ansible_hostname }}$"
name: "{{ ansible_hostname }}"
path: OU=Domain Servers,OU=Site-Location,DC=ad,DC=cityofgotham,DC=com
type: computer
All of these entries are needed at a minimum to get it to work. Oddly enough sometimes during my testing, it would create completely identical named computer objects that were disabled. That is less than desirable. Hopefully this will help someone.
from microsoft.ad.
Hi,
we solved it with two tasks:
- name: "Search computer object in ad to fetch guid [ad_manage_computer_add]"
microsoft.ad.object_info:
ldap_filter: "(&(objectClass=computer)(cn={{ inventory_hostname_short }}*))"
properties: '*'
domain_server: ADCONTROLLER
domain_username: ADMIN
domain_password: PASSWORD
delegate_to: ADCONTROLLER
register: reg_computer_obj
- name: "Move computer object to the right Active Directory OU [ad_manage_computer_add]"
microsoft.ad.object:
identity: "{{ reg_computer_obj.objects.0.ObjectGUID }}"
name: "{{ inventory_hostname_short }}"
path: "CN=Computers,DC=domain,DC=com"
type: computer
domain_server: ADCONTROLLER
domain_username: ADMIN
domain_password: PASSWORD
state: present
delegate_to: ADCONTROLLER
Hope that helps...
from microsoft.ad.
You are correct in that using identity
will just use the filter (sAMAccountName=$identity)
and not add the $
to the end. I think the logic should be amended so that for resources that are known to end with $
it should automatically added to the filter string so you don't have to.
Thanks for looking into this and providing all that great detail!
from microsoft.ad.
So is the thought to change that so it appends a $ to the identity to see if it finds a match? Also could add the example to the documentation afterwards? Please let me know if I can do anything else to help, thanks!
from microsoft.ad.
Yea I think it makes sense that when we are dealing with an object type that is known to always end with $
it will automatically append $
if it's not already there when searching by sAMAccountName
.
Documentation is also a great idea!
from microsoft.ad.
I've opened #137 which adds a fallback identity check with $
for microsoft.ad.computer
. It also adds the ability to create a computer account without the $
suffix alongside some more tests for these scenarios.
from microsoft.ad.
Related Issues (20)
- New Release of microsoft.ad HOT 1
- microsoft.ad.group module : Set members to an empty list HOT 3
- microsoft.ad.group module : Set members list HOT 3
- microsoft.ad.user - New-ADUser failed: A parameter cannot be found that matches parameter name 'LockedOut' HOT 1
- microsoft.ad.user - Created user not found while deleting by ad-hoc command HOT 1
- Error: The term 'Get-ADRootDSE' is not recognized as the name of a cmdlet HOT 5
- Error: Skip computer 'x' with new name 'x' because the new name is the same as the current name. HOT 1
- Getting an error while running the microsoft.ad module HOT 1
- New-ADObject failed: The security descriptor is invalid HOT 1
- Feature request: "flatten" option for microsoft.ad.group
- Incorrect diff output for multiple-choice options HOT 2
- Unable to add built-in group members HOT 3
- Add optional server argument to allow join to specific domain controller. HOT 3
- AD User creation bombs out when attempting to add an AD Group of higher security permissions than the service account HOT 1
- `microsoft.ad.group` fails with `members.set` set to an empty list on new objects HOT 1
- Nesting groups not working microsoft.ad.groups HOT 9
- Remove-ADObject: The object class of the instance object must contain 'top'. when trying to delete a computer account HOT 3
- microsoft.ad.membership could not reboot after join workgroup HOT 2
- MANIFEST.json required for installation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microsoft.ad.