### Make GET Request to Adaxes SDK (Node.js) Source: https://www.adaxes.com/sdk/REST_SearchDirectory2021 A Node.js example for making a GET request to the Adaxes SDK using the `fetch` API. It demonstrates constructing the request URL with encoded parameters and handling the JSON response. ```javascript async function searchDirectory() { // Request parameters const ldapFilter = encodeURIComponent("(employeeId=MyId12345)"); const propertiesToGet = encodeURIComponent("employeeId"); const baseUrl = "https://host.example.com/restapi"; const endpoint = "/api/directoryObjects/search"; const queryParams = `?filter=${ldapFilter}&properties=${propertiesToGet}`; const requestPath = `${baseUrl}${endpoint}${queryParams}`; // Make request const response = await fetch(requestPath, { method: "GET", headers: { "Adm-Authorization": "YOUR-ACCESS-TOKEN" } }); if (!response.ok) { throw new Error(`Request failed with status ${response.status}`); } const result = await response.json(); console.log(result); } searchDirectory(); ``` -------------------------------- ### Make GET Request to Adaxes SDK (Python) Source: https://www.adaxes.com/sdk/REST_SearchDirectory2021 Shows how to make a GET request to the Adaxes SDK using the Python `requests` library. This example includes setting headers and passing query parameters as a dictionary. ```python import requests import json baseUrl = "https://host.example.com/restApi" endpoint = "/api/directoryObjects/search" # Request parameters requestUrl = baseUrl + endpoint requestHeaders = {"Adm-Authorization": "YOUR-ACCESS-TOKEN"} queryParams = { "filter": "(employeeId=MyId12345)", "properties": "employeeId" } # Make request request = requests.get(requestUrl, headers=requestHeaders, params=queryParams) response = json.loads(request.content) print(response) ``` -------------------------------- ### Make GET Request to Adaxes SDK (C#) Source: https://www.adaxes.com/sdk/REST_SearchDirectory2021 Provides a C# example for making a GET request to the Adaxes SDK. It utilizes `HttpClient` to send the request and handle the asynchronous response. Ensure the `System.Net.Http` namespace is included. ```C# using System; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { const string baseUrl = "https://host.example.com"; const string endpoint = "/restApi/api/directoryObjects/search"; // Request parameters string ldapFilter = HttpUtility.UrlEncode("(employeeId=MyId12345)"); const string propertiesToGet = "employeeId"; UriBuilder requestUrl = new() { Host = baseUrl + endpoint, Query = $"?filter={ldapFilter}" + $"&properties={propertiesToGet}" }; // Initialize HTTP client using HttpClient client = new(); client.DefaultRequestHeaders.Add("Adm-Authorization", "YOUR-ACCESS-TOKEN"); // Make request string response = await client.GetStringAsync(requestUrl.ToString()); Console.WriteLine(response); } } ``` -------------------------------- ### Make GET Request to Adaxes SDK (cURL) Source: https://www.adaxes.com/sdk/REST_SearchDirectory2021 Illustrates how to make a GET request to the Adaxes SDK using the cURL command-line tool. This example shows how to set headers and pass URL-encoded query parameters. ```bash curl --header 'Adm-Authorization: YOUR-ACCESS-TOKEN' \ --get -X GET 'https://host.example.com/restApi/api/directoryObjects/search' \ --data-urlencode 'filter=(employeeId=MyId12345)' \ --data-urlencode 'properties=employeeId' ``` -------------------------------- ### Reset Computer Account Example (Node.js) Source: https://www.adaxes.com/sdk/REST_ResetComputer A Node.js example demonstrating the reset computer account functionality using the fetch API. It defines the base URL, endpoint, constructs the request body, and sends the POST request with appropriate headers. ```JavaScript async function resetAccount() { // Request parameters const baseUrl = "https://host.example.com/restapi"; const endpoint = "/api/directoryObjects/account/reset"; const requestPath = `${baseUrl}${endpoint}`; // Create JSON request body const requestBody = { directoryObject: "CN=MYCOMPUTER,OU=Computers,DC=example,DC=com" }; // Make request const response = await fetch(requestPath, { method: "POST", headers: { "Adm-Authorization": "YOUR-ACCESS-TOKEN", "Content-Type": "application/json" }, body: JSON.stringify(requestBody) }); if (!response.ok) { throw new Error(`Request failed with status ${response.status}`); } const result = await response.json(); console.log(result); } resetAccount(); ``` -------------------------------- ### Get Configuration Container GUID - PowerShell and C# Source: https://www.adaxes.com/sdk/IAdmServiceBackend2 Retrieves the GUID of a well-known container storing Adaxes configuration objects. This method requires the container's alias as input. Examples are provided for both PowerShell and C#. ```PowerShell Import-Module Adaxes # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") Write-Host $service.Backend.GetConfigurationContainerGuid("BusinessRules") ``` ```C# using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); IAdmServiceBackend2 backend = (IAdmServiceBackend2)service.Backend; Console.WriteLine(backend.GetConfigurationContainerGuid("BusinessRules")); } } ``` -------------------------------- ### Update Directory Object - GUID Identifier Example Source: https://www.adaxes.com/sdk/REST_UpdateDirectoryObject Example of a Globally Unique Identifier (GUID) format used to identify a directory object for updates. ```text 7a4267ce-d354-44e7-8bd6-c681f1284a41 ``` -------------------------------- ### Adaxes SDK Example: All Users and Computers Criteria Source: https://www.adaxes.com/sdk/REST_CriteriaJson Illustrates how to create criteria to match all user and computer objects. This is a basic example showing how to specify object types without any specific conditions. ```json { "objectTypes": [ { "type": "user", "items": {} }, { "type": "computer", "items": {} } ] } ``` -------------------------------- ### Get All Group Members using IAdmGroup (PowerShell) Source: https://www.adaxes.com/sdk/IAdmGroup Retrieves GUIDs of all members (direct and indirect) of an Adaxes group. It connects to the Adaxes service, binds to a specified group, and then accesses the AllMembers property to get an array of byte arrays representing the GUIDs. This snippet focuses on retrieving the GUIDs and does not include further processing. ```PowerShell Import-Module Adaxes # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Bind to the group. $groupDN = "CN=Sales Managers,CN=Groups,DC=domain,DC=com" $group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0) # Get GUIDs of all members of the group. $memberGuidsBytes = $group.AllMembers ``` -------------------------------- ### Reset Computer Account Example (cURL) Source: https://www.adaxes.com/sdk/REST_ResetComputer Illustrates how to reset a computer account using the cURL command-line tool. This example shows the necessary headers and the raw JSON data payload for the POST request. ```cURL curl --header 'Adm-Authorization: YOUR-ACCESS-TOKEN' \ --header 'Content-Type: application/json' \ --request POST 'https://host.example.com/restApi/api/directoryObjects/account/reset' \ --data-raw '{ "directoryObject": "CN=MYCOMPUTER,OU=Computers,DC=example,DC=com" }' ``` -------------------------------- ### Adaxes API: Example of GUID for 'createIn' Attribute Source: https://www.adaxes.com/sdk/REST_CreateDirectoryObject This example shows how to specify the 'createIn' attribute using a Globally Unique Identifier (GUID). This is an alternative method to using a Distinguished Name (DN) for locating the target container. ```text # Example 0b4d238a-62fc-4088-0ff3-4ae2b108eed4 ``` -------------------------------- ### Create User with Certificate - PowerShell Source: https://www.adaxes.com/sdk/New-AdmUser This PowerShell example demonstrates how to create a new user account and import an X.509 certificate for it. It utilizes the New-AdmUser cmdlet and requires a certificate file. ```powershell New-AdmUser -Name "ChewDavid" -Certificate (New-Object System.Security.Cryptography.X509Certificates.X509Certificate -ArgumentList "Export.cer") ``` -------------------------------- ### Create Container Object with Path and Server (PowerShell) Source: https://www.adaxes.com/sdk/New-AdmObject This example illustrates creating a new container object. It specifies the Name, Type, the Path where the container should be created, and the Server to use for the operation. ```powershell New-AdmObject -Name "Apps" -Type "container" -Path "DC=AppNC" -Server "FABRIKAM-SRV1:60000" ``` -------------------------------- ### Get Next Page of Search Results - PowerShell Example Source: https://www.adaxes.com/sdk/IAdmSearchResultIterator An example demonstrating how to get the next page of search results using PowerShell with the Adaxes SDK. It shows connecting to the Adaxes service and binding to an organizational unit to initiate a search. ```powershell Import-Module Adaxes $ouDN = "OU=Contacts,DC=domain,DC=com" # Connect to the Adaxes service. $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the organizational unit. $searcher = $service.OpenObject("Adaxes://$ouDN", $null, $null, 0) ``` -------------------------------- ### LastRunStartDateTime Property Source: https://www.adaxes.com/sdk/IAdmScheduledTask Gets the date and time when the scheduled task was last started. Returns DateTime.MinValue if never started. ```APIDOC ## LastRunStartDateTime ### Description Gets the date and time when the scheduled task was last started. If the scheduled task was never started, the property gets `DateTime.MinValue`. The property gets the date and time in the local time zone of the computer where the Adaxes service is running. ### Type DateTime ### Access Read-only ### Example ```powershell # Retrieving the last run start time # Assuming $myTask is an IAdmScheduledTask object $lastRunStart = $myTask.LastRunStartDateTime Write-Host "Last Run Start: $lastRunStart" ``` ``` -------------------------------- ### Reset Computer Account Example (PowerShell) Source: https://www.adaxes.com/sdk/REST_ResetComputer Demonstrates how to reset a computer account using PowerShell. It constructs the request URL, headers, and body, then sends a POST request using Invoke-RestMethod. ```PowerShell $baseUrl = "https://host.example.com/restApi" $endpoint = "/api/directoryObjects/account/reset" # Request parameters $requestUrl = $baseUrl + $endpoint $requestHeaders = @{"Adm-Authorization" = "YOUR-ACCESS-TOKEN"} $requestBody = ConvertTo-Json @{"directoryObject" = "CN=MYCOMPUTER,OU=Computers,DC=example,DC=com"} # Make request Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl ` -Body $requestBody -ContentType "application/json" ``` -------------------------------- ### Get Approver Group GUID by Index - Adaxes SDK Source: https://www.adaxes.com/sdk/IAdmApproverGroups Retrieves the globally unique identifier (GUID) of an approver group at a specified index. The GUID is returned as a 16-byte array (Byte[]). ```csharp Byte[] GetObjectGuid(int index) ``` -------------------------------- ### Get Specific Computer with All Properties (PowerShell) Source: https://www.adaxes.com/sdk/Get-AdmComputer This example demonstrates how to retrieve a specific Active Directory computer object and display all of its available properties using the Get-AdmComputer cmdlet. It requires the computer's name and the '-Properties *' parameter to fetch all attributes. ```powershell Get-AdmComputer "Fabrikam-SRV1" -Properties * DistinguishedName : CN=Fabrikam-SRV1,CN=Computers,DC=fabrikam,DC=com ObjectClass : computer CN : Fabrikam-SRV1 Created : 1/21/2020 6:06:59 AM DisplayName : Fabrikam-SRV1$ Modified : 1/21/2020 6:07:00 AM ObjectCategory : CN=Computer,CN=Schema,CN=Configuration,DC=fabrikam,DC=com Name : Fabrikam-SRV1 ObjectGUID : 17b61380-9069-4579-a913-6afc3c04d664 ProtectedFromAccidentalDeletion : False SamAccountName : Fabrikam-SRV1$ SID : S-1-5-21-2718492785-1413807572-3629993048-2094144 AccountNotDelegated : False AllowReversiblePasswordEncryption : False CannotChangePassword : False DoesNotRequirePreAuth : False Enabled : True HomedirRequired : False LockedOut : False ManagedBy : CN=SQL Administrator 01,OU=UserAccounts,OU=Managed,DC=fabrikam,DC=com MNSLogonAccount : False PasswordExpired : False PasswordNeverExpires : False PasswordNotRequired : True PrimaryGroup : CN=Domain Computers,CN=Users,DC=fabrikam,DC=com TrustedForDelegation : False TrustedToAuthForDelegation : False UseDESKeyOnly : False codepage : 0 iscriticalsystemobject : False usnchanged : 65348869 instancetype : 4 ntsecuritydescriptor : {1, 0, 4, 140...} samaccounttype : 805306369 usncreated : 65348869 dscorepropagationdata : 1/1/1601 12:00:00 AM localpolicyflags : 0 whencreated : 1/21/2020 12:06:59 PM adspath : LDAP://fabrikam.com/CN=Fabrikam-SRV1,CN=Computers,DC=fabrikam,DC=com countrycode : 0 whenchanged : 1/21/2020 12:07:00 PM accountexpires : 9223372036854775807 ``` -------------------------------- ### Create GUID Based Searcher (Adaxes SDK) Source: https://www.adaxes.com/sdk/GenerateReportScriptContextClass Creates a directory searcher configured for objects with specified GUIDs. Each GUID should be a 16-byte array. Example shows adding group members to a report. ```PowerShell $groupDN = "CN=SalesGroup,CN=Groups,DC=domain,DC=com" # Bind to group $group = $Context.BindToObjectByDN($groupDN) # Get GUIDs of direct group members $memberGuidsBytes = $group.DirectMembers # Create a directory searcher instance $searcher = $Context.CreateGuidBasedSearcher($memberGuidsBytes) # Add search results to report $Context.Items.Add($searcher) ``` -------------------------------- ### Reset Computer Account Example (Python) Source: https://www.adaxes.com/sdk/REST_ResetComputer This Python script shows how to reset a computer account using the requests library. It sets up the URL, headers, and request body, then performs a POST request and prints the JSON response. ```Python import requests import json baseUrl = "https://host.example.com/restApi" endpoint = "/api/directoryObjects/account/reset" # Request parameters requestUrl = baseUrl + endpoint requestHeaders = {"Adm-Authorization": "YOUR-ACCESS-TOKEN"} requestBody = {"directoryObject": "CN=MYCOMPUTER,OU=Computers,DC=example,DC=com"} # Make request request = requests.post(requestUrl, headers=requestHeaders, json=requestBody) response = json.loads(request.content) print(response) ``` -------------------------------- ### Get Business Unit Member GUIDs (C#) Source: https://www.adaxes.com/sdk/IAdmBusinessUnit Returns an array of GUIDs for objects matching the provided membership rules. Each GUID is a Byte[] (16 bytes), and the method returns a Byte[][] (array of byte arrays). ```csharp object[] GetMemberGuids(IAdmBusinessUnitMembershipRules membershipRules) ``` -------------------------------- ### Reset Computer Account Example (C#) Source: https://www.adaxes.com/sdk/REST_ResetComputer Provides a C# code example for resetting a computer account. It utilizes System.Net.Http.HttpClient to send a POST request with the appropriate headers and JSON body. ```C# using System; using System.Text; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { const string baseUrl = "https://host.example.com/restApi"; const string endpoint = "/api/directoryObjects/account/reset"; // Create JSON request body string jsonRequest = @" {{ ""directoryObject"": ""CN=MYCOMPUTER,OU=Computers,DC=example,DC=com"" }}"; StringContent requestBody = new(jsonRequest, Encoding.UTF8, "application/json"); // Initialize HTTP client using HttpClient client = new(); client.DefaultRequestHeaders.Add("Adm-Authorization", "YOUR-ACCESS-TOKEN"); // Make request HttpResponseMessage response = await client.PostAsync( baseUrl + endpoint, requestBody); string responseBody = response.Content.ReadAsStringAsync().Result; Console.WriteLine(responseBody); } } ``` -------------------------------- ### Enrollment Invitation Settings Source: https://www.adaxes.com/sdk/IAdmPasswordSelfServicePolicy Configure settings related to sending enrollment invitations to users. ```APIDOC ## GET /websites/adaxes_sdk/policies/passwordSelfService/enrollmentInvitation ### Description Retrieves the current settings for enrollment invitations. ### Method GET ### Endpoint /websites/adaxes_sdk/policies/passwordSelfService/enrollmentInvitation ### Parameters None ### Request Example None ### Response #### Success Response (200) - **EnrollmentInvitationEnabled** (bool) - Indicates if enrollment invitations are enabled. - **EnrollmentInvitationSubject** (string) - The subject of the enrollment invitation email. - **EnrollmentInvitationText** (string) - The body text of the enrollment invitation email. - **EnrollmentInvitationFrequency** (ADM_ENROLLINVITATIONFREQUENCY_ENUM) - How often enrollment invitations are sent. #### Response Example ```json { "EnrollmentInvitationEnabled": true, "EnrollmentInvitationSubject": "Password Enrollment Invitation", "EnrollmentInvitationText": "Dear %name%, please enroll for password self-service.", "EnrollmentInvitationFrequency": "Daily" } ``` ## PUT /websites/adaxes_sdk/policies/passwordSelfService/enrollmentInvitation ### Description Updates the settings for enrollment invitations. ### Method PUT ### Endpoint /websites/adaxes_sdk/policies/passwordSelfService/enrollmentInvitation ### Parameters #### Request Body - **EnrollmentInvitationEnabled** (bool) - Required - Indicates if enrollment invitations should be enabled. - **EnrollmentInvitationSubject** (string) - Optional - The subject of the enrollment invitation email. - **EnrollmentInvitationText** (string) - Optional - The body text of the enrollment invitation email. - **EnrollmentInvitationFrequency** (ADM_ENROLLINVITATIONFREQUENCY_ENUM) - Optional - How often enrollment invitations should be sent. ### Request Example ```json { "EnrollmentInvitationEnabled": true, "EnrollmentInvitationSubject": "Password Enrollment Invitation", "EnrollmentInvitationText": "Dear %name%, please enroll for password self-service.", "EnrollmentInvitationFrequency": "Daily" } ``` ### Response #### Success Response (200) - **Success** (bool) - Indicates if the update was successful. #### Response Example ```json { "Success": true } ``` ``` -------------------------------- ### Get Object GUID using ADsPath Property Source: https://www.adaxes.com/sdk/IADs Retrieves the globally unique identifier (GUID) of an object stored in the directory. The GUID is returned as a hexadecimal string and can be used to bind directly to the directory object. ```Adaxes SDK Adaxes://servername/ ``` -------------------------------- ### Create AD Computer Account - Basic Source: https://www.adaxes.com/sdk/New-AdmComputer Creates a new Active Directory computer account with a specified name, SAM account name, and path to the organizational unit (OU). If the path is omitted, the computer is created in the default container. ```powershell New-AdmComputer -Name "FABRIKAM-SRV2" -SamAccountName "FABRIKAM-SRV2" -Path "OU=ApplicationServers,OU=ComputerAccounts,OU=Managed,DC=FABRIKAM,DC=COM" ``` -------------------------------- ### Get Assigned Object GUIDs using IAdmReportCategory Source: https://www.adaxes.com/sdk/IAdmReportCategory Retrieves the GUIDs of objects of a specified type assigned to a report category. The assigneeType parameter specifies the type of objects for which to return GUIDs. This method is part of the IAdmReportCategory interface. ```C# string[] GetAssignedObjectGuids(ADM_REPORTCATEGORYASSIGNEETYPE_ENUM assigneeType) ``` -------------------------------- ### Get Direct Group GUIDs for User in PowerShell and C# Source: https://www.adaxes.com/sdk/IAdmTop Retrieves the GUIDs of all groups a user is a direct member of. It then iterates through these GUIDs to open each group object and display its name. Requires the Adaxes SDK and a connection to the Adaxes service. ```PowerShell Write-Host "Group names:" foreach ($groupGuidBytes in $groupGuidsBytes) { # Bind to the group. $guid = [Guid]$groupGuidBytes $guidPath = "Adaxes://" $group = $service.OpenObject($guidPath, $null, $null, 0) # Get the group name. Write-Host " " $group.Get("name") } ``` ```C# using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the target user. const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com"; IAdmTop user = (IAdmTop) service.OpenObject(userPath, null, null, 0); // Get GUIDs of all groups the user is a direct member of. object[] groupGuidsBytes = (object[]) user.DirectMemberOf; Console.WriteLine("Group names:"); foreach (Byte[] groupGuidBytes in groupGuidsBytes) { // Bind to the group. string guid = new Guid(groupGuidBytes).ToString("B"); string guidPath = $"Adaxes://"; IADs group = (IADs) service.OpenObject(guidPath, null, null, 0); // Output the group name. Console.WriteLine(" {0}", group.Get("name")); } } } ``` -------------------------------- ### User Profile and Directory Settings Source: https://www.adaxes.com/sdk/IADsTSUserEx Configures user-specific directories, drives, and initial programs for RD Session Host environments. ```APIDOC ## User Profile and Directory Settings ### Description Configures user-specific directories, drives, and initial programs for RD Session Host environments. ### Method GET/SET (Implied by property access) ### Endpoint N/A (Represents a property) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Represents the current profile and directory settings. #### Response Example ```json { "TerminalServicesHomeDirectory": "C:\Users\UserProfiles", "TerminalServicesHomeDrive": "D:", "TerminalServicesInitialProgram": "C:\Program Files\MyApp\App.exe", "TerminalServicesWorkDirectory": "C:\Program Files\MyApp", "TerminalServicesProfilePath": "\\Server\Profiles\UserName" } ``` **Properties:** * **TerminalServicesHomeDirectory** (string) - Gets or sets the root directory for the user. Each user on an RD Session Host server has a unique root directory. This ensures that application information is stored separately for each user in a multiuser environment. (For network environments, set `TerminalServicesHomeDrive` first.) * **TerminalServicesHomeDrive** (string) - Gets or sets the root drive for the user. In a network environment, this property is a string that contains a drive specification (a drive letter followed by a colon) to which the UNC path specified in the `TerminalServicesHomeDirectory` property is mapped. * **TerminalServicesInitialProgram** (string) - Gets or sets the path and file name of the application that the user wants to start automatically when the user logs on to the RD Session Host server. (To set, also set `TerminalServicesWorkDirectory`.) * **TerminalServicesProfilePath** (string) - Gets or sets the roaming or mandatory profile path to be used when the user logs on to the Remote Desktop Session Host (RD Session Host) server. (Format: `\ServerNameProfilesFolderNameUserName`) * **TerminalServicesWorkDirectory** (string) - Gets or sets the working directory path for the user. (Required when setting `TerminalServicesInitialProgram`.) ``` -------------------------------- ### Create New Computer Object with ManagedByList (PowerShell) Source: https://www.adaxes.com/sdk/New-AdmComputer Demonstrates how to create a new Active Directory computer object using the New-AdmComputer cmdlet in PowerShell. It shows how to specify multiple users or groups as managers using the -ManagedByList parameter, providing their distinguished names, GUIDs, or SIDs. The example requires the -AdaxesService parameter. ```powershell $ $owners = @( "CN=John Smith,CN=Users,DC=example,DC=com", "{75444639-7DAF-460F-AFAF-04CE891A4AF0}", "S-1-5-21-318736562-1752376529-4243903518-874036" ) New-AdmComputer -Name "MY-WORKSTATION" -SamAccountName "MY-WORKSTATION" -ManagedByList $owners \ -Path "CN=Computers,DC=example,DC=com" -AdaxesService localhost ``` -------------------------------- ### Move Object by GUID to New Location - PowerShell Source: https://www.adaxes.com/sdk/Move-AdmObject Illustrates moving an Active Directory object identified by its globally unique identifier (GUID) to a new target OU. This example shows how to use a GUID for the object's identity. ```powershell Move-AdmObject "8d0bcc44-c826-4dd8-af5c-2c69960fbd47" -TargetPath "OU=Managed,DC=Fabrikam,DC=Com" ``` -------------------------------- ### Create AD Computer Account - With Properties Source: https://www.adaxes.com/sdk/New-AdmComputer Creates a new Active Directory computer account, enabling it and setting its location within a specified OU. This demonstrates setting common properties like 'Enabled' and 'Location' during creation. ```powershell New-AdmComputer -Name "FABRIKAM-SRV3" -SamAccountName "FABRIKAM-SRV3" -Path "OU=ApplicationServers,OU=ComputerAccounts,OU=Managed,DC=FABRIKAM,DC=COM" -Enabled $true -Location "Redmond,WA" ``` -------------------------------- ### Rename Directory Object by GUID (PowerShell) Source: https://www.adaxes.com/sdk/Rename-AdmObject This example shows how to rename a directory object using its globally unique identifier (GUID). The Identity parameter accepts the GUID string, and the NewName parameter defines the object's new name. ```powershell Rename-AdmObject -Identity "4777c8e8-cd29-4699-91e8-c507705a0966" -NewName "DavidAhs" ``` -------------------------------- ### Get Report Category GUIDs (Adaxes SDK) Source: https://www.adaxes.com/sdk/IAdmReportCategoryQueries Retrieves an array of GUIDs for report categories associated with a given generator type. This method is part of the IAdmReportCategoryQueries interface. ```csharp string[] GetCategoryGuids(ADM_REPORTGENERATORTYPE_ENUM generatorType) ``` -------------------------------- ### Create a Business Rule (C#) Source: https://www.adaxes.com/sdk/ManagingBusinessRules This C# code sample illustrates the creation of a business rule that executes after user account creation. It utilizes the Adaxes SDK to connect to the Adaxes service, bind to the appropriate container, and then instantiate and configure the new business rule. ```C# using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; using Softerra.Adaxes.Interop.Adsi.BusinessRules; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the business rules container. string containerPath = service.Backend.GetConfigurationContainerPath("BusinessRules"); IADsContainer container = (IADsContainer)service.OpenObject( containerPath, null, null, 0); // Create a new business rule. IAdmBusinessRule rule = (IAdmBusinessRule)container.Create( "adm-BusinessRule", "CN=My Rule"); rule.ExecutionMoment = ADM_BUSINESSRULEEXECMOMENT_ENUM.ADM_BUSINESSRULEEXECMOMENT_AFTER; rule.ObjectType = "user"; rule.OperationType = "create"; rule.Disabled = false; // Save the business rule. rule.SetInfo(); } } ``` -------------------------------- ### Create GUID-Based Directory Searcher (PowerShell) Source: https://www.adaxes.com/sdk/ExecuteScriptContextClass Creates a directory searcher configured to find objects by their GUIDs. Each GUID should be provided as a 16-byte array. This method is useful for efficiently searching for objects when their GUIDs are known. Supported starting with Adaxes version 2018.1. ```PowerShell $groupDN = "CN=SalesGroup,CN=Groups,DC=domain,DC=com" # Bind to group $group = $Context.BindToObjectByDN($groupDN) # Get GUIDs of direct group members $memberGuidsBytes = $group.DirectMembers # Create a directory searcher instance $searcher = $Context.CreateGuidBasedSearcher($memberGuidsBytes) try { # Execute search $searchResultIterator = $searcher.ExecuteSearch() $searchResults = $searchResultIterator.FetchAll() } finally { # Release resources if ($searchResultIterator) { $searchResultIterator.Dispose() } } # Update group members description foreach ($searchResult in $searchResults) { $member = $Context.BindToObjectBySearchResult($searchResult) $member.Put("description", "My description") $member.SetInfo() } ``` -------------------------------- ### Connect to AD Server with -Server Source: https://www.adaxes.com/sdk/New-AdmComputer The -Server parameter specifies the Active Directory Domain Services instance to connect to. It accepts domain names (FQDN or NetBIOS) or directory server names (FQDN, NetBIOS, or FQDN with port). The default is determined by pipeline objects, the provider drive, or the local computer's domain. ```powershell # Example: Connect to a specific domain controller Get-AdmUser -Filter * -Server "dc01.example.com" ``` -------------------------------- ### HomePage Parameter Source: https://www.adaxes.com/sdk/New-AdmComputer Sets the home page URL for an Active Directory object. ```APIDOC ## HomePage Parameter ### Description Specifies the URL of the object home page. This parameter sets the _homePage_ property of an Active Directory object. The LDAP name of the property is _wWWHomePage_. ### Method Not Applicable (Cmdlet Parameter) ### Endpoint Not Applicable (Cmdlet Parameter) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```powershell -HomePage "http://www.example.com" ``` ### Response #### Success Response (200) Not Applicable (Cmdlet Parameter) #### Response Example Not Applicable (Cmdlet Parameter) ``` -------------------------------- ### TaskID Property Source: https://www.adaxes.com/sdk/IAdmScheduledTask Gets the globally unique identifier (GUID) of the scheduled task. ```APIDOC ## TaskID ### Description Gets the globally unique identifier (GUID) of the scheduled task. ### Type string ### Access Read-only ### Example ```powershell # Retrieving the task ID # Assuming $myTask is an IAdmScheduledTask object $taskID = $myTask.TaskID Write-Host "Task ID: $taskID" ``` ``` -------------------------------- ### PowerShellInstalled Property Source: https://www.adaxes.com/sdk/IAdmLyncEnableDisableAction Gets a value indicating whether Windows PowerShell is installed on the computer where the Adaxes service is running. ```APIDOC ## PowerShellInstalled ### Description Gets a value indicating whether Windows PowerShell is installed on the computer where the Adaxes service is running. ### Type bool ### Access Read-only ``` -------------------------------- ### New-AdmComputer Source: https://www.adaxes.com/sdk/Get-AdmComputer Creates a new Active Directory computer object. This cmdlet allows specifying various properties for the new computer, including its identity, location, and other AD attributes. ```APIDOC ## NEW-ADMCOMPUTER ### Description Creates a new Active Directory computer object. ### Method POST (conceptual, as this is a cmdlet) ### Endpoint Not applicable (PowerShell cmdlet) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **Identity** (Softerra.Adaxes.PowerShellModule.Directory.ADComputer) - Required - The identity of the computer object to create. - **Server** (string) - Optional - Specifies the Active Directory Domain Services instance to connect to. Can be a fully qualified domain name, NetBIOS name, or directory server name (with optional port). - **Properties** (object) - Optional - A set of additional properties to retrieve for the computer object. ### Request Example ```powershell New-AdmComputer -Identity "CN=NewComputer,OU=Users,DC=example,DC=com" -Server "dc01.example.com" ``` ### Response #### Success Response (200) - **ADComputer** (Softerra.Adaxes.PowerShellModule.Directory.ADComputer) - Returns the newly created computer object with default properties. #### Response Example ```json { "Name": "NewComputer", "SamAccountName": "NewComputer$", "DistinguishedName": "CN=NewComputer,OU=Users,DC=example,DC=com" } ``` ``` -------------------------------- ### Create Criteria for Objects Starting with 'Admin' (PowerShell) Source: https://www.adaxes.com/sdk/New-AdmCriteria Creates a Criteria object that matches all objects where the 'name' property starts with 'Admin'. This example uses the '-startstwith' operator within the expression. ```powershell New-AdmCriteria -Expression {name -startstwith "Admin"} ``` -------------------------------- ### Create and Save Business Unit in C# Source: https://www.adaxes.com/sdk/ManagingBusinessUnits Demonstrates how to connect to the Adaxes service, bind to a container, create a new business unit, set its description and membership rules, and then save the changes. This requires the Softerra.Adaxes.Interop.Adsi libraries. ```csharp using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Interop.Adsi.BusinessUnits; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the business units container. string containerPath = service.Backend.GetConfigurationContainerPath("BusinessUnits"); // Build the ADS path of the nested container 'My Container' and bind to it. AdsPath businessUnitsPath = new AdsPath(containerPath); AdsPath myContainerPath = businessUnitsPath.CreateChildPath("CN=My Container"); IADsContainer myContainer = (IADsContainer)service.OpenObject( myContainerPath.ToString(), null, null, 0); // Create a new business unit. IAdmBusinessUnit unit = (IAdmBusinessUnit)myContainer.Create("adm-BusinessUnit", "CN=My Unit"); unit.Description = "My description"; IAdmBusinessUnitMembershipRules rules = unit.GetMembershipRules(); // [TODO] define membership rules // Save the business unit. unit.SetMembershipRules(rules); unit.SetInfo(); } } ``` -------------------------------- ### Retrieve Business Unit Members (cURL) Source: https://www.adaxes.com/sdk/REST_GetBusinessUnitMembers This example uses cURL to make a GET request to retrieve business unit members. It includes the necessary authorization header and query parameters for filtering. ```cURL curl --header 'Adm-Authorization: YOUR-ACCESS-TOKEN' \ --get -X GET 'https://host.example.com/restApi/api/directoryObjects/businessUnitMembers' \ --data-urlencode 'businessUnit=CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes' ``` -------------------------------- ### Make GET Request to Adaxes SDK API Source: https://www.adaxes.com/sdk/REST_GetDirectoryObject This snippet shows how to make a GET request to the Adaxes SDK to retrieve directory object details. It includes parameters for the user identifier and properties to fetch. The response is a JSON object containing account and password status, GUID, DN, and other properties. ```powershell Invoke-RestMethod -Method GET -Headers $requestHeaders -Uri $requestUrl -Body $queryParams ``` ```csharp using System; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { const string baseUrl = "https://host.example.com"; const string endpoint = "/restApi/api/directoryObjects"; // Request parameters const string userIdentifier = "CN=John Smith,CN=Users,DC=example,DC=com"; const string propertiesToGet = "adm-O365AccountLocation,adm-O365AccountBlocked,adm-O365AccountLicenses"; UriBuilder requestUrl = new() { Host = baseUrl + endpoint, Query = $"?directoryObject={userIdentifier}" + $"&properties={propertiesToGet}" }; // Initialize HTTP client using HttpClient client = new(); client.DefaultRequestHeaders.Add("Adm-Authorization", "YOUR-ACCESS-TOKEN"); // Make request string response = await client.GetStringAsync(requestUrl.ToString()); Console.WriteLine(response); } } ``` ```curl curl --header 'Adm-Authorization: YOUR-ACCESS-TOKEN' \ --get -X GET 'https://host.example.com/restApi/api/directoryObjects' \ --data-urlencode 'directoryobject=CN=John Smith,CN=Users,DC=example,DC=com' \ --data-urlencode 'properties=adm-O365AccountLocation,adm-O365AccountBlocked,adm-O365AccountLicenses' ``` ```javascript async function getDirectoryObject() { // Request parameters const userIdentifier = encodeURIComponent("CN=John Smith,CN=Users,DC=example,DC=com"); const propertiesToGet = encodeURIComponent( "adm-O365AccountLocation,adm-O365AccountBlocked,adm-O365AccountLicenses" ); const baseUrl = "https://host.example.com/restapi"; const endpoint = "/api/directoryObjects"; const queryParams = `?directoryobject=${userIdentifier}&properties=${propertiesToGet}`; const requestPath = `${baseUrl}${endpoint}${queryParams}`; // Make request const response = await fetch(requestPath, { method: "GET", headers: { "Adm-Authorization": "YOUR-ACCESS-TOKEN" } }); if (!response.ok) { throw new Error(`Request failed with status ${response.status}`); } const result = await response.json(); console.log(result); } getDirectoryObject(); ``` ```python import requests import json baseUrl = "https://host.example.com/restApi" endpoint = "/api/directoryObjects" # Request parameters requestUrl = baseUrl + endpoint requestHeaders = {"Adm-Authorization": "YOUR-ACCESS-TOKEN"} queryParams = { "directoryObject": "CN=John Smith,CN=Users,DC=example,DC=com", "properties": "adm-O365AccountLocation,adm-O365AccountBlocked,adm-O365AccountLicenses" } # Make request request = requests.get(requestUrl, headers=requestHeaders, params=queryParams) response = json.loads(request.content) print(response) ``` -------------------------------- ### Create AD Computer Account - From Template Source: https://www.adaxes.com/sdk/New-AdmComputer Creates a new Active Directory computer account using an existing computer object as a template. Properties like 'Location' and 'OperatingSystem' are copied from the template, and can be overridden by cmdlet parameters. ```powershell $templateComp = Get-AdmComputer "LabServer-00" -Properties "Location","OperatingSystem","OperatingSystemHotfix","OperatingSystemServicePack","OperatingSystemVersion" New-AdmComputer -Instance $templateComp -Name "LabServer-01" ``` -------------------------------- ### Make GET Request to Adaxes SDK Source: https://www.adaxes.com/sdk/REST_GetBusinessUnitMembers Demonstrates how to make a GET request to the Adaxes SDK to retrieve business unit members. This example shows how to construct the request URL with parameters for the business unit identifier and desired properties, and how to handle the response. It requires an access token for authentication. ```powershell Invoke-RestMethod -Method GET -Headers $requestHeaders -Uri $requestUrl -Body $queryParams ``` ```csharp using System; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { const string baseUrl = "https://host.example.com"; const string endpoint = "/restApi/api/directoryObjects/businessUnitMembers"; // Request parameters const string unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"; const string propertiesToGet = "department,accountExpires"; UriBuilder requestUrl = new() { Host = baseUrl + endpoint, Query = $"?businessUnit={unitIdentifier}" + $"&properties={propertiesToGet}" }; // Initialize HTTP client using HttpClient client = new(); client.DefaultRequestHeaders.Add("Adm-Authorization", "YOUR-ACCESS-TOKEN"); // Make request string response = await client.GetStringAsync(requestUrl.ToString()); Console.WriteLine(response); } } ``` ```curl curl --header 'Adm-Authorization: YOUR-ACCESS-TOKEN' \ --get -X GET 'https://host.example.com/restApi/api/directoryObjects/businessUnitMembers' \ --data-urlencode 'businessUnit=CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes' \ --data-urlencode 'properties=department,accountExpires' ``` ```javascript async function getBusinessUnitMembers() { // Request parameters const unitIdentifier = encodeURIComponent("CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"); const propertiesToGet = encodeURIComponent("department,accountExpires"); const baseUrl = "https://host.example.com/restapi"; const endpoint = "/api/directoryObjects/businessUnitMembers"; const queryParams = `?businessUnit=${unitIdentifier}&properties=${propertiesToGet}`; const requestPath = `${baseUrl}${endpoint}${queryParams}`; // Make request const response = await fetch(requestPath, { method: "GET", headers: { "Adm-Authorization": "YOUR-ACCESS-TOKEN" } }); if (!response.ok) { throw new Error(`Request failed with status ${response.status}`); } const result = await response.json(); console.log(result); } getBusinessUnitMembers(); ``` ```python import requests import json baseUrl = "https://host.example.com/restApi" endpoint = "/api/directoryObjects/businessUnitMembers" # Request parameters requestUrl = baseUrl + endpoint requestHeaders = {"Adm-Authorization": "YOUR-ACCESS-TOKEN"} queryParams = { "businessUnit": "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes", "properties": "department,accountExpires" } # Make request request = requests.get(requestUrl, headers=requestHeaders, params=queryParams) response = json.loads(request.content) print(response) ``` -------------------------------- ### IAdmLocationCondition Examples Source: https://www.adaxes.com/sdk/IAdmLocationCondition Code examples demonstrating how to create and configure an IAdmLocationCondition in PowerShell and C#. ```APIDOC ## Examples ### PowerShell Example This example creates a condition that returns `true` if the object is located directly under the _London Staff_ organizational unit. ```powershell # The $actionSet variable refers to an action set in a # business rule, custom command, or scheduled task. # Create condition. $condition = $actionSet.Conditions.CreateEx("adm-LocationCondition") $locationCondition = $condition.GetCondition() $locationCondition.IsOperator = "ADM_ISOPERATOR_IS" $locationCondition.Scope = "ADS_SCOPE_ONELEVEL" $ouDN = "OU=London Staff,DC=company,DC=com" $ou = $service.OpenObject("Adaxes://$ouDN", $null, $null, 0) $locationCondition.Container = $ou # Save changes. $condition.SetCondition($locationCondition) $condition.SetInfo() $actionSet.Conditions.Add($condition) ``` ### C# Example This example creates a condition that returns `true` if the object is located directly under the _London Staff_ organizational unit. ```csharp // The actionSet variable refers to an action set in a // business rule, custom command, or scheduled task. // Create condition. IAdmBusinessRuleCondition condition = (IAdmBusinessRuleCondition)actionSet.Conditions.CreateEx( "adm-LocationCondition"); IAdmLocationCondition locationCondition = (IAdmLocationCondition)condition.GetCondition(); locationCondition.IsOperator = ADM_ISOPERATOR_ENUM.ADM_ISOPERATOR_IS; locationCondition.Scope = ADS_SCOPEENUM.ADS_SCOPE_ONELEVEL; const string ouDN = "OU=London Staff,DC=company,DC=com"; IADsContainer ou = (IADsContainer)service.OpenObject($"Adaxes://{ouDN}", null, null, 0); locationCondition.Container = ou; // Save changes. condition.SetCondition(locationCondition); condition.SetInfo(); actionSet.Conditions.Add(condition); ``` ``` -------------------------------- ### Adaxes API: PowerShell Example for Creating a User Source: https://www.adaxes.com/sdk/REST_CreateDirectoryObject This PowerShell script demonstrates how to construct and send a request to create a user account using the Adaxes REST API. It sets common user properties like first name, last name, username, and password. ```powershell $baseUrl = "https://host.example.com/restApi" $endpoint = "/api/directoryObjects" ```