|
21 | 21 |
|
22 | 22 | aadsync_server= "adminwebservice.microsoftonline.com" |
23 | 23 | aadsync_client_version="8.0" |
24 | | -aadsync_client_build= "2.2.8.0" |
| 24 | +aadsync_client_build= "2.4.21.0" |
25 | 25 | client_id = "04b07795-8ddb-461a-bbee-02f9e1bf7b46" |
26 | 26 |
|
27 | 27 | class AADInternals(): |
@@ -299,19 +299,25 @@ def get_groupsmembers(self,objectid,pagesize=500,sortdirection="Ascending",sortf |
299 | 299 |
|
300 | 300 |
|
301 | 301 |
|
302 | | - #https://github.com/Gerenios/AADInternals/blob/fd6474e840f457c32a297cadbad051cabe2a019b/ProvisioningAPI.ps1#L3404 |
| 302 | + #https://github.com/microsoftgraph/entra-powershell/blob/af0c8b538d293390ce0c2fafe30b95259cdcf774/module/Entra/Microsoft.Entra/DirectoryManagement/Set-EntraDirSyncEnabled.ps1#L44 |
303 | 303 | def set_adsyncenabled(self,enabledirsync=True): |
304 | | - """ |
305 | | - Enables or disables directory synchronization using provisioning API. |
306 | | - Enabling / disabling the synchrnoization usually takes less than 10 seconds. Check the status using Get-AADIntCompanyInformation. |
307 | | - """ |
308 | | - body = '''<b:EnableDirSync>%s</b:EnableDirSync>''' % str(bool(enabledirsync)).lower() |
309 | | - command = "SetCompanyDirSyncEnabled" |
310 | | - envelope = self.create_envelope(command,body) |
311 | | - response = self.call_provisioningapi(envelope) |
312 | | - return self.xml_to_result(response,command) |
313 | 304 |
|
| 305 | + url = f"https://graph.microsoft.com/v1.0/organization/{self.tenant_id}" |
| 306 | + token = self.get_token(['https://graph.microsoft.com/.default']) |
| 307 | + headers = { |
| 308 | + "Authorization": f"Bearer {token}", |
| 309 | + "Content-Type": "application/json" |
| 310 | + } |
314 | 311 |
|
| 312 | + body = {"OnPremisesSyncEnabled": enabledirsync} |
| 313 | + |
| 314 | + response = requests.patch(url, json=body, headers=headers,proxies=self.proxies) |
| 315 | + |
| 316 | + if response.status_code == 204: |
| 317 | + return |
| 318 | + else: |
| 319 | + raise Exception (response.content) |
| 320 | + |
315 | 321 | #https://github.com/Gerenios/AADInternals/blob/fd6474e840f457c32a297cadbad051cabe2a019b/ProvisioningAPI.ps1#L5561 |
316 | 322 | def set_userlicenses(self,objectid): |
317 | 323 | body = rf'''<b:AddLicenses i:nil="true"/> |
|
0 commit comments