95 lines
3.1 KiB
C#

//----------------------------------------------------------------------------
//
// Copyright (c) Intel Corporation, 2011 - 2014 All Rights Reserved.
//
//----------------------------------------------------------------------------
using System;
using System.IO;
using Intel.Manageability;
using Intel.Manageability.Exceptions;
using Common.Utils;
using System.Runtime.InteropServices;
namespace ACLSample
{
class Program
{
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetDefaultDllDirectories(int directoryFlags);
static void Main(string[] args)
{
// set default dll lookup directory to system
SetDefaultDllDirectories(0x00000800); //LOAD_LIBRARY_SEARCH_SYSTEM32
IAMTInstance amt = null;
ConnectionInfoEX ci = null;
try
{
// Check if JSON path was provided as an argument. If not, default path would be used.
try
{
ci = ProgramInput.DeserializeJsonToStruct(args.Length > 0 ? args[0] : null);
}
catch (IOException e)
{
Console.WriteLine($"Could not read argument file: {e.Message}");
return;
}
amt = AMTInstanceFactory.CreateEX(ci);
}
catch (ManageabilityException e)
{
Console.WriteLine(e.Message);
return;
}
try
{
// Create or update digest user.
ACLFunctionality.CreateOrUpdateDigestUser(amt);
// Get digest user by his name.
ACLFunctionality.GetDigestUser(amt, "DigestUser");
// Get all digest users.
ACLFunctionality.GetAllDigestUsers(amt);
// Delete digest user by his name.
ACLFunctionality.DeleteDigestUser(amt, "DigestUser");
// Create a kerberos user with the user's domain\username.
// The user must already be defined in Active Directory when creating the ACL Kerberos entry.
ACLFunctionality.CreateOrUpdateKerberosUser(amt, "Intel\\KerberosUser");
// Get kerberos user by his Domain\UserName
ACLFunctionality.GetKerberosUser(amt, "Intel\\KerberosUser");
// Get all kerberos users
ACLFunctionality.GetAllKerberosUsers(amt);
// Delete kerberos user by his SID
ACLFunctionality.DeleteKerberosUser(amt, "Intel\\KerberosUser");
// Update Admin user
ACLFunctionality.UpdateAdminUser(amt, "Admin", "p@ssw0rd");
// Get user name of the Admin user
ACLFunctionality.GetAdminUser(amt);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
amt?.Dispose();
}
}
}
}