• Products
    • View all products
    • Free trials
  • Solutions
    • All Solutions
    • All Integrations
  • Resources
    • All Resources
    • Learning Hub
  • Trials
  • Support
    • Support Home
    • By Product
      • All Products
      • Active Roles
      • Authentication Services
      • Cloud Access Manager
      • Defender
      • Identity Manager
      • Password Manager
      • Safeguard
      • Starling Identity Analytics & Risk Intelligence
      • Starling Two-Factor Authentication
      • TPAM Appliance
    • Contact Support
      • Overview
      • Customer Service
      • Licensing Assistance
      • Renewal Assistance
      • Technical Support
    • Download Software
    • Knowledge Base
    • My Account
      • My Products
      • My Service Requests
      • My Licenses
      • My Groups
      • My Profile
    • Policies & Procedures
    • Professional Services
    • Technical Documentation
    • One Identity University
    • User Forums
    • Video Tutorials
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Communities
    • Home
    • Blogs
      • Blogs A to Z
      • One Identity Community
      • AD Account Lifecycle Management
      • Cloud
      • Identity Governance & Administration
      • Privileged Access Management
      • syslog-ng Community
    • Forums
      • All Product Forums
      • Active Roles
      • Identity Manager
      • Password Manager
      • Safeguard
      • Unix Access Management
    • Social Networks
      • Facebook
      • LinkedIn
      • Twitter
      • YouTube
One Identity Community
One Identity Community
  • Site
  • User
  • Site
  • Search
  • User
Active Roles Community
Active Roles Community
Wiki C#: SPML Search example
  • Forum
  • Ideas
  • Wiki
  • More
  • Cancel
  • New
  • -Active Roles Script Center
    • +Active Roles Script Policy Best Practices
    • Active Roles SDK
    • -C#
      • -C# samples
        • C#: Approval-aware modify operation
        • C#: SPML Creating an user
        • C#: SPML Search example
    • +JavaScript
    • +PowerShell
    • +VBScript

C#: SPML Search example

Steps to reproduce the sample.

1. Install SPML provider (included with the Active Roles Installation media under \Solutions\SPML Provider) to a computer with IIS.

2. Ensure it works. Open url "http://<computer_host>/ARServerSPML/SPMLProvider.asmx".

3. Create a C# console project.

4. "Add Service Reference...", put url from point 2, and rename the reference to "ArsSPML".

5. Open a file "Program.cs" and put this code.

6. Run the project.

DESCRIPTION

This C# sample code demonstrates how to search for users by Active Roles SPML provider. Users displayName that starts with 'S' or contains 'Admin'.

Note This code may use interfaces from Active Roles ADSI Provider Type Library (EDMLib). Please, add a reference to the Active Roles ADSI Provider Type Library (EDMLib) to your C# project.

CODE

//********************************************************************************

// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

//

// IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,

// PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.

//*********************************************************************************

using System;

using System.Collections.Generic;

using System.Linq;

using System.Security.Principal;

namespace SPMLComplexSearchSample

{

using ArsSPML;

class Program

{

static void Main()

{

// Create request object

var request = new CSearchRequest();

// Find active users with displayName starts with 'S' or contains 'Admin';

var filter = new CQueryFilter();

var isUser = new equalityMatch { name = "objectClass", value = "user" };

var isActive = new isActive();

var isStartsWith = new substrings { name = "displayName", initial = "S" };

var isContains = new substrings { name = "displayName", any = new[] { "Admin" } };

filter.Items = new[] {

new and { Items = new object[] // root condition must be allways single

{

isUser, isActive,

new or { Items = new[] { isStartsWith, isContains} }

} } };

request.query = new CQuery();

request.query.filter = filter;

request.query.basePsoID = new CPSOID1 { ID = "DC=arsdev,DC=msk,DC=qsft" };

request.query.scope = "subTree";

request.query.attributes = CreateAttributes(new[] { "cn", "givenName", "l", "displayName" });

request.returnData = "everything";

// Create web service instance

var webService = new QuestOneActiveRolesSPMLProviderSoapClient();

webService.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;

// Send request and get response

var response = webService.search(request);

if (!String.IsNullOrEmpty(response.errorMessage))

Console.WriteLine(response.errorMessage);

else

{

if (response.pso != null)

{

foreach (var pso in response.pso)

{

Console.WriteLine(pso.psoID.ID);

foreach (var attr in pso.data)

{

var value = attr.value.Aggregate(string.Empty, (result, next) => result + next + ";");

Console.WriteLine("{0}: {1}", attr.name, value);

}

Console.WriteLine();

}

}

}

Console.WriteLine("Done.");

Console.ReadKey();

}

static attribute[] CreateAttributes(IEnumerable<string> names)

{

return names.Select(name => new attribute { name = name }).ToArray();

}

}

}

//***** END OF CODE ***************************************************************

  • Script Center: C#
  • Script Center
  • Share
  • History
  • More
  • Cancel
Related
Recommended
  • Company
    • About Us
    • Buy
    • Careers
    • Contact Us
    • News
  • Resources
    • Blogs
    • Customer Stories
    • Documents
    • Events
    • Videos
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • One Identity University
    • Support Service
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2025 One Identity LLC. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center