I have the below code that imports a solution into CRM Dynamics.
The code executes successfully and the import job data returns a result of success. How ever when I look for the solution in Settings->Solutions it is not there. Can anyone suggest a fix?
private void ImportSolution(string solutionPath)
{
byte[] fileBytes = File.ReadAllBytes(solutionPath);
var request = new ImportSolutionRequest()
{
CustomizationFile = fileBytes,
ImportJobId = Guid.NewGuid()
};
var response = _settings.DestinationSourceOrgService.Execute(request);
var improtJob = new ImportJob(_settings);
var importJobResult = improtJob.GetImportJob(request.ImportJobId);
var data = importJobResult.Attributes["data"].ToString();
var jobData = new ImportJobData(data);
var filePath = $#"{this._settings.SolutionExportDirectory}\Logs\";
var fileName = $#"{filePath}{jobData.SolutionName}.xml";
Directory.CreateDirectory(filePath);
File.WriteAllText(fileName, data);
PrintResult(jobData.Result, jobData.SolutionName);
}
public class ImportJob
{
private readonly ConfigurationSettings _settings;
public ImportJob(ConfigurationSettings settings)
{
_settings = settings;
}
public Entity GetImportJob(Guid importJobId)
{
var query = new QueryExpression
{
EntityName = "importjob",
ColumnSet = new ColumnSet("importjobid", "data", "solutionname"),
Criteria = new FilterExpression()
};
var result = _settings.DestinationSourceOrgService.Retrieve("importjob", importJobId, new ColumnSet("importjobid", "data", "solutionname", "progress"));
return result;
}
}
Thre ImportSolutionResponse does not contain any information as per the screen shot below.
Related
I need to be able to mock IDocumentQuery, to be able to test piece of code, that queries document collection and might use predicate to filter them:
IQueryable<T> documentQuery = client
.CreateDocumentQuery<T>(collectionUri, options);
if (predicate != null)
{
documentQuery = documentQuery.Where(predicate);
}
var list = documentQuery.AsDocumentQuery();
var documents = new List<T>();
while (list.HasMoreResults)
{
documents.AddRange(await list.ExecuteNextAsync<T>());
}
I've used answer from https://stackoverflow.com/a/49911733/212121 to write following method:
public static IDocumentClient Create<T>(params T[] collectionDocuments)
{
var query = Substitute.For<IFakeDocumentQuery<T>>();
var provider = Substitute.For<IQueryProvider>();
provider
.CreateQuery<T>(Arg.Any<Expression>())
.Returns(x => query);
query.Provider.Returns(provider);
query.ElementType.Returns(collectionDocuments.AsQueryable().ElementType);
query.Expression.Returns(collectionDocuments.AsQueryable().Expression);
query.GetEnumerator().Returns(collectionDocuments.AsQueryable().GetEnumerator());
query.ExecuteNextAsync<T>().Returns(x => new FeedResponse<T>(collectionDocuments));
query.HasMoreResults.Returns(true, false);
var client = Substitute.For<IDocumentClient>();
client
.CreateDocumentQuery<T>(Arg.Any<Uri>(), Arg.Any<FeedOptions>())
.Returns(query);
return client;
}
Which works fine as long as there's no filtering using IQueryable.Where.
My question:
Is there any way to capture predicate, that was used to create documentQuery and apply that predicate on collectionDocuments parameter?
Access the expression from the query provider so that it will be passed on to the backing collection to apply the desired filter.
Review the following
public static IDocumentClient Create<T>(params T[] collectionDocuments) {
var query = Substitute.For<IFakeDocumentQuery<T>>();
var queryable = collectionDocuments.AsQueryable();
var provider = Substitute.For<IQueryProvider>();
provider.CreateQuery<T>(Arg.Any<Expression>())
.Returns(x => {
var expression = x.Arg<Expression>();
if (expression != null) {
queryable = queryable.Provider.CreateQuery<T>(expression);
}
return query;
});
query.Provider.Returns(_ => provider);
query.ElementType.Returns(_ => queryable.ElementType);
query.Expression.Returns(_ => queryable.Expression);
query.GetEnumerator().Returns(_ => queryable.GetEnumerator());
query.ExecuteNextAsync<T>().Returns(x => new FeedResponse<T>(query));
query.HasMoreResults.Returns(true, true, false);
var client = Substitute.For<IDocumentClient>();
client
.CreateDocumentQuery<T>(Arg.Any<Uri>(), Arg.Any<FeedOptions>())
.Returns(query);
return client;
}
The important part is where the expression passed to the query is used to create another query on the backing data source (the array).
Using the following example subject under test for demonstration purposes.
public class SubjectUnderTest {
private readonly IDocumentClient client;
public SubjectUnderTest(IDocumentClient client) {
this.client = client;
}
public async Task<List<T>> Query<T>(Expression<Func<T, bool>> predicate = null) {
FeedOptions options = null; //for dummy purposes only
Uri collectionUri = null; //for dummy purposes only
IQueryable<T> documentQuery = client.CreateDocumentQuery<T>(collectionUri, options);
if (predicate != null) {
documentQuery = documentQuery.Where(predicate);
}
var list = documentQuery.AsDocumentQuery();
var documents = new List<T>();
while (list.HasMoreResults) {
documents.AddRange(await list.ExecuteNextAsync<T>());
}
return documents;
}
}
The following sample tests when an expression is passed to the query
[TestMethod]
public async Task Should_Filter_DocumentQuery() {
//Arrange
var dataSource = Enumerable.Range(0, 3)
.Select(_ => new Document() { Key = _ }).ToArray();
var client = Create(dataSource);
var subject = new SubjectUnderTest(client);
Expression<Func<Document, bool>> predicate = _ => _.Key == 1;
var expected = dataSource.Where(predicate.Compile());
//Act
var actual = await subject.Query<Document>(predicate);
//Assert
actual.Should().BeEquivalentTo(expected);
}
public class Document {
public int Key { get; set; }
}
I have tabbed pages in my project where I have to bind same few items in all the three tabbed pages.But the viewmodel is not executing in that.
xaml :
<TabbedPage.Children>
<Views:TabPage1>
<Views:TabPage1.BindingContext>
<ViewModel:TabPage1VM/>
</Views:TabPage1.BindingContext>
</Views:TabPage1>
<Views:TabPage2>
<Views:TabPage2.BindingContext>
<ViewModel:TabPage2VM/>
</Views:TabPage2.BindingContext>
</Views:TabPage2>
<Views:TabPage3>
<Views:TabPage3.BindingContext>
<ViewModel:TabPage3VM/>
</Views:TabPage3.BindingContext>
</Views:TabPage3>
</TabbedPage.Children>
Now each Viewmodel is inheriting the main Viewmodel and in one child ViewModel :
RestClient temp = new RestClient();
var gettempdetails = temp.Servicetypes();
if (gettempdetails.status == "success")
{
listdetails = new List<ServiceDetail>();
foreach (Datum2 data in gettempdetails.service_details)
{
Datum3 Display = new Datum2();
Display.name = data.name;
Display.rate = data.rate;
Display.time = data.time;
Display.type = data.type;
Display.image = "uncheck.png";
}
While debugging, the above code is not executing.
Any Solution?
Also here is the code for RestClient inside the child viewmodel:
public RestClient()
{
client = new HttpClient
{
MaxResponseContentBufferSize = 256000
};
}
public async Task<ServiceItem> Servicetypes(int shopid)
{
var formcontent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string,string>("branch_id",Convert.ToString(shopid)),
});
var response = await client.PostAsync("http://saloonbooking.com/index.php/branch/get_single_branch_details/", formcontent);
var data = await response.Content.ReadAsStringAsync();
var status = JsonConvert.DeserializeObject<ServiceItem>(data);
return status;
We are developing a Pipeline for which we have to add over 100 steps and modify two things for each step: Step Name and PackageID.
Rather than going through the pain of doing this via the UI, we’d like to do this programmatically.
Below is some C# I’ve sketched out for this (I’m a C# developer with extremely limited PowerShell skills, that’s why I did this in C#).
The lines above the comment “From here on is where I'm fuzzy” are working code, but the lines below the comment are just pseudocode.
Can someone explain to me how to write the lines below the comment (or, the PowerShell equivalent)?
I wasn’t able to find API calls for this.
Thanks
namespace ODClientExample
{
class Program
{
static void Main(string[] args)
{
List<string> ListOfWindowsServices = new List<string>();
ListOfWindowsServices.Add("svc1");
ListOfWindowsServices.Add("svc2");
ListOfFWindowsServices.Add("svc3");
var server = "https://mysite.whatever/";
var apiKey = "API-xxxxxxxxxxxxxxxxxx"; // I generated this via the Octopus UI
var endpoint = new OctopusServerEndpoint(server, apiKey);
var repository = new OctopusRepository(endpoint);
var project = repository.Projects.FindByName("Windows Services");
// From here on is where I'm fuzzy:
//
var procesSteps = GetProcessSteps(project);
var processStepToClone = GetProcesStepByName(processSteps, "SomeProcessStep");
foreach (string svcName in ListofSvcNames)
{
processStepToClone.StepName = svcName;
processStepToClone.PackageID = svcName;
}
}
}
}
I've made a little more progress. I'm now able to access the Steps in the Process, and add a Step. However, when my code calls repository.DeploymentProcesses.Modify, I get this exception:
Please provide a value for the package ID.
Please select the feed that this package will be downloaded from.
Please select one or more roles that 'svc1' step will apply to.
Here's my latest code:
static void Main(string[] args)
{
List<string> ListOfFexWindowsServices = new List<string>();
ListOfFexWindowsServices.Add("svc2");
ListOfFexWindowsServices.Add("svc3");
ListOfFexWindowsServices.Add("svc4");
string server = "https://mysite.stuff/";
string apiKey = "API-xxxxxxxxxxxxxxxxxxxxxxxx"; // I generated this via the Octopus UI
OctopusServerEndpoint endpoint = new OctopusServerEndpoint(server, apiKey);
OctopusRepository repository = new OctopusRepository(endpoint);
ProjectResource projectResource = repository.Projects.FindByName("MyProject");
DeploymentProcessResource deploymentProcess = repository.DeploymentProcesses.Get(projectResource.DeploymentProcessId);
var projectSteps = deploymentProcess.Steps;
DeploymentStepResource stepToClone = new DeploymentStepResource();
foreach (DeploymentStepResource step in projectSteps)
{
if (step.Name == "svc1")
{
stepToClone = step;
break;
}
}
foreach (string serviceName in ListOfFexWindowsServices)
{
DeploymentStepResource newStep = new DeploymentStepResource();
PopulateNewStep(newStep, stepToClone, serviceName);
deploymentProcess.Steps.Add(newStep);
repository.DeploymentProcesses.Modify(deploymentProcess);
}
}
static void PopulateNewStep(DeploymentStepResource newStep, DeploymentStepResource stepToClone, string serviceName)
{
newStep.Name = serviceName;
newStep.Id = Guid.NewGuid().ToString();
newStep.StartTrigger = stepToClone.StartTrigger;
newStep.Condition = stepToClone.Condition;
DeploymentActionResource action = new DeploymentActionResource
{
Name = newStep.Name,
ActionType = "Octopus.TentaclePackage",
Id = Guid.NewGuid().ToString(),
};
PopulateActionProperties(action);
newStep.Actions.Add(action);
// ISSUE: Anything else to do (eg, any other things from stepToClone to copy, or other stuff to create)?
newStep.PackageRequirement = stepToClone.PackageRequirement;
}
static void PopulateActionProperties(DeploymentActionResource action)
{
action.Properties.Add(new KeyValuePair<string, PropertyValueResource>("Octopus.Action.WindowsService.CustomAccountPassword", "#{WindowsService.Password}"));
// TODO: Repeat this sort of thing for each Action Property you see in stepToClone.
}
void Main()
{
var sourceProjectName = "<source project name>";
var targetProjectName = "<target project name>";
var stepToCopyName = "<step name to copy>";
var repo = GetOctopusRepository();
var sourceProject = repo.Projects.FindByName(sourceProjectName);
var targetProject = repo.Projects.FindByName(targetProjectName);
if (sourceProject != null && targetProject != null)
{
var sourceDeploymentProcess = repo.DeploymentProcesses.Get(sourceProject.DeploymentProcessId);
var targetDeploymentProcess = repo.DeploymentProcesses.Get(targetProject.DeploymentProcessId);
if (sourceDeploymentProcess != null && targetDeploymentProcess != null)
{
Console.WriteLine($"Start copy from project '{sourceProjectName}' to project '{targetProjectName}'");
CopyStepToTarget(sourceDeploymentProcess, targetDeploymentProcess, stepToCopyName);
// Update or add the target deployment process
repo.DeploymentProcesses.Modify(targetDeploymentProcess);
Console.WriteLine($"End copy from project '{sourceProjectName}' to project '{targetProjectName}'");
}
}
}
private OctopusRepository GetOctopusRepository()
{
var octopusServer = Environment.GetEnvironmentVariable("OCTOPUS_CLI_SERVER");
var octopusApiKey = Environment.GetEnvironmentVariable("OCTOPUS_CLI_API_KEY");
var endPoint = new OctopusServerEndpoint(octopusServer, octopusApiKey);
return new OctopusRepository(endPoint);
}
private void CopyStepToTarget(DeploymentProcessResource sourceProcess, DeploymentProcessResource targetProcess, string sourceStepName, bool includeChannels = false, bool includeEnvironments = false)
{
var sourceStep = sourceProcess.FindStep(sourceStepName);
if (sourceStep == null)
{
Console.WriteLine($"{sourceStepName} not found in {sourceProcess.ProjectId}");
return;
}
Console.WriteLine($"-> copy step '{sourceStep.Name}'");
var stepToAdd = targetProcess.AddOrUpdateStep(sourceStep.Name);
stepToAdd.RequirePackagesToBeAcquired(sourceStep.RequiresPackagesToBeAcquired);
stepToAdd.WithCondition(sourceStep.Condition);
stepToAdd.WithStartTrigger(sourceStep.StartTrigger);
foreach (var property in sourceStep.Properties)
{
if (stepToAdd.Properties.ContainsKey(property.Key))
{
stepToAdd.Properties[property.Key] = property.Value;
}
else
{
stepToAdd.Properties.Add(property.Key, property.Value);
}
}
foreach (var sourceAction in sourceStep.Actions)
{
Console.WriteLine($"-> copy action '{sourceAction.Name}'");
var targetAction = stepToAdd.AddOrUpdateAction(sourceAction.Name);
targetAction.ActionType = sourceAction.ActionType;
targetAction.IsDisabled = sourceAction.IsDisabled;
if (includeChannels)
{
foreach (var sourceChannel in sourceAction.Channels)
{
targetAction.Channels.Add(sourceChannel);
}
}
if (includeEnvironments)
{
foreach (var sourceEnvironment in sourceAction.Environments)
{
targetAction.Environments.Add(sourceEnvironment);
}
}
foreach (var actionProperty in sourceAction.Properties)
{
if (targetAction.Properties.ContainsKey(actionProperty.Key))
{
targetAction.Properties[actionProperty.Key] = actionProperty.Value;
}
else
{
targetAction.Properties.Add(actionProperty.Key, actionProperty.Value);
}
}
}
}
The above code sample is available in the Octopus Client Api Samples
I have created an HTTP Client that sends data to my server. This data will query my server that will return a JSON object. How can I receive the JSON Object response from my server and insert it into my database?
The code below will send a ContactID to my server and my server will return a JSON Object How can I get the JSON Object from my server? What will I add to my code? I have added
var data = await response.Content.ReadAsStringAsync();
but I don't know how to proceed.
try
{
var db = DependencyService.Get<ISQLiteDB>();
var conn = db.GetConnection();
var sql = "SELECT * FROM tblUser WHERE ContactID = '" + contact + "'";
var getUser = conn.QueryAsync<UserTable>(sql);
var resultCount = getUser.Result.Count;
//Check if the user has been sync
if (resultCount < 1)
{
try
{
syncStatus.Text = "Syncing user to server...";
var link = Constants.requestUrl + "Host=" + host + "&Database=" + database + "&Contact=" + contact + "&Request=8qApc8";
string contentType = "application/json";
JObject json = new JObject
{
{ "ContactID", contact }
};
HttpClient client = new HttpClient();
var response = await client.PostAsync(link, new StringContent(json.ToString(), Encoding.UTF8, contentType));
var data = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var userresult = JsonConvert.DeserializeObject<IList<UserData>>(content);
var count = userresult.Count;
for (int i = 0; i < count; i++)
{
try
{
syncStatus.Text = "Syncing user to server...";
var item = userresult[i];
var contactID = item.ContactID;
var userID = item.UserID;
var userPassword = item.UserPassword;
var userType = item.UserType;
var userStatus = item.UserStatus;
var lastSync = item.LastSync;
var serverUpdate = item.ServerUpdate;
var mobileUpdate = item.MobileUpdate;
var user = new UserTable
{
ContactID = Convert.ToInt32(contactID),
UserID = userID,
UserPassword = userPassword,
UserType = userType,
UserStatus = userStatus,
LastSync = lastSync,
ServerUpdate = serverUpdate,
MobileUpdate = mobileUpdate
};
await conn.InsertAsync(user);
}
catch (Exception ex)
{
Console.Write("Syncing user error " + ex.Message);
}
}
}
}
catch (Exception ex)
{
Console.Write("Syncing User Error " + ex.Message);
}
}
My PHP code will query my database with the ContactID received from Xamarin HTTP Client.
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str);
$ContactID = $json_obj->ContactID;
$sql = "SELECT * FROM tblUser WHERE ContactID = '$ContactID'";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if($count > 0){
while ($row = #mysqli_fetch_array($result)) {
$decr = CryptRC4(FromHexDump($row['UserPassword']), $key);
$ar[] = array(
'ContactID' => $row['ContactID'],
'UserID' => $row['UserID'],
'UserPassword' => $decr,
'UserType' => $row['UserType'],
'UserStatus' => $row['UserStatus'],
'LastSync' => $sync,
'ServerUpdate' => $row['ServerUpdate'],
'MobileUpdate' => $row['MobileUpdate']
);
print json_encode($ar);
//Update LastSync DateTime
$sql = "UPDATE tblUser SET LastSync = '$sync' WHERE ContactID = '$ContactID'";
mysqli_query($conn, $sql);
}
}
Last statement in your example above gives list of json objects in string format.
var data = await response.Content.ReadAsStringAsync();
You need to convert that back to list of objects. To let your project know about definition of the object, create a plain class with public properties (Something like below)
public class UserLog
{
public int ContactId { get; set; }
public string Log { get; set; }
public DateTime LogDate { get; set; }
}
Add Newtonsoft.Json (by James Newton-King) Nuget package to your project so that you can work with json.
To convert content of the variable 'data' into list of UserLog objects, write code like
var list = NewtonsoftUtil<IList<UserLog>>.DeserializeObject(data);
(Add using Newtonsoft.Json; at top of the file)
Please let me know if this helps.
The answers above missing one important point -> efficiency.
There is no need to allocate a string in memory, especially if your JSON is big. Streams can do much better then strings:
// Read the response as stream
var stream = await response.Content.ReadAsStreamAsync();
// Use the next method for deserialization
T DeserializeJsonFromStream<T>(Stream stream)
{
if (stream == null || stream.CanRead == false)
return default(T);
using (var sr = new StreamReader(stream))
using (var jtr = new JsonTextReader(sr))
{
var js = new JsonSerializer();
return js.Deserialize<T>(jtr);
}
}
P.S.: Code example is bases on Json.NET.
P.S.S.: There are many good articles on this topic, I could recommend to get familiar with the next one.
Assuming that you have done everything correctly. In other words, You're be able to sent your contactID and get back a json.
Let's say your json structure is something like:
{"firstname" : "Doe",
"lastname" : "foo"
"age" : "27"}
One possible way to retrieve the data is as below:
using Newtonsoft.Json;
//after PostAsync()
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
JObject jContent = (JObject)JsonConvert.DeserializeObject(content);
string firstName = (string)jContent.GetValue("firstname")
string lastName = (string)jContent.GetValue("lastname");
int age = (int)jContent.GetValue("age");
}
Newtonsoft is available on Nuget. you need to install it if you have not done so.
Improved solution
What if your json has many key/values pairs like below:
{ key1 : value1,
key2 : value2,
key3 : value3,
...
key10 : value10}
Then it is not a good idea by doing :
string foo1 = (string)jContent.GetValue("key1");
string foo2 = (string)jContent.GetValue("key2");
//...
string foo10 = (string)jContent.GetValue("key10");
To handle this case, you can create a class:
public class Foo
{
public string Foo1 {get;set;}
public string Foo2 {get;set;}
//...
public string Foo2 {get;set;}
}
Then, you can do as simple as below:
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
Foo foo = JsonConvert.DeserializeObject<Foo>(content);
}
The improved solution referecnced from www.newtonsoft.com. Go there and check out other ways of using the library.
I am trying to read
All Groups of Users in Windows
Permissions (ACL, DACL etc) on each group.
Here is my code
public List<GroupPermissions> GetGroups()
{
var scope = new ManagementScope("\\\\.\\ROOT\\cimv2");
var sQuery = new SelectQuery("Select * from Win32_SecurityDescriptor");
var secDesc = new List<GroupPermissions>();
try
{
var mSearcher = new ManagementObjectSearcher(scope,sQuery);
foreach (ManagementObject mObject in mSearcher.Get())
{
var sDObj = new GroupPermissions();
var aceList = new List<ACE>();
var saceList = new List<ACE>();
var aceobjs = (ManagementObjectCollection)mObject["DACL"];
var aceobjsS = (ManagementObjectCollection)mObject["SACL"];
var gpTt = (ManagementObject)mObject["Group"];
var ownerTt = (ManagementObject)mObject["Owner"];
var sids = (UInt16[]) gpTt["SID"];
var osids= (UInt16[]) ownerTt["SID"];
var groupTrustee = new Trustee()
{
Domain =Convert.ToString(gpTt["Domain"]),
Name = Convert.ToString(gpTt["Name"]),
SIDString = Convert.ToString(gpTt["SIDString"]),
SidLength = Convert.ToUInt32(gpTt["SidLength"]),
SID = sids
};
var ownerTrustee = new Trustee()
{
Domain =Convert.ToString(ownerTt["Domain"]),
Name = Convert.ToString(ownerTt["Name"]),
SIDString = Convert.ToString(ownerTt["SIDString"]),
SidLength = Convert.ToUInt32(ownerTt["SidLength"]),
SID = osids
};
foreach (ManagementObject ace in aceobjs)
{
var dTrustee = (ManagementObject)ace["Trustee"];
var daclSids= (UInt16[]) dTrustee ["SID"];
var daclTrustee = new Trustee()
{
Domain =Convert.ToString(gpTt["Domain"]),
Name = Convert.ToString(gpTt["Name"]),
SIDString = Convert.ToString(gpTt["SIDString"]),
SidLength = Convert.ToUInt32(gpTt["SidLength"]),
SID = daclSids
};
aceList.Add(new ACE()
{
AccessMask = Convert.ToUInt32(ace["AccessMask"]),
AceFlags = Convert.ToUInt32(ace["AceFlags"]),
GuidInheritedObjectType = Convert.ToString(ace["GuidInheritedObjectType"]),
AceType = Convert.ToUInt32(ace["AceType"]),
GuidObjectType = Convert.ToString(ace["GuidObjectType"]),
Trustee = daclTrustee
});
}
foreach (ManagementObject sace in aceobjsS)
{
var dTrustee = (ManagementObject)sace["Trustee"];
var daclSids = (UInt16[])dTrustee["SID"];
var daclTrustee = new Trustee()
{
Domain = Convert.ToString(gpTt["Domain"]),
Name = Convert.ToString(gpTt["Name"]),
SIDString = Convert.ToString(gpTt["SIDString"]),
SidLength = Convert.ToUInt32(gpTt["SidLength"]),
SID = daclSids
};
saceList.Add(new ACE()
{
AccessMask = Convert.ToUInt32(sace["AccessMask"]),
AceFlags = Convert.ToUInt32(sace["AceFlags"]),
GuidInheritedObjectType = Convert.ToString(sace["GuidInheritedObjectType"]),
AceType = Convert.ToUInt32(sace["AceType"]),
GuidObjectType = Convert.ToString(sace["GuidObjectType"]),
Trustee = daclTrustee
});
}
sDObj.ControlFlags = Convert.ToUInt32(mObject["ControlFlags"] ?? 0);
sDObj.DACL = aceList.ToArray();
sDObj.Group = groupTrustee;
sDObj.Owner = ownerTrustee;
sDObj.SACL = saceList.ToArray();
secDesc.Add(sDObj);
}
}
catch (Exception ex)
{
}
return secDesc;
}
and dependent classes that i have created (in copy of WMI classes)
public class GroupPermissions
{
public UInt32 ControlFlags;
public ACE[] DACL;
public Trustee Group;
public Trustee Owner;
public ACE[] SACL;
}
public class ACE
{
public UInt32 AccessMask;
public UInt32 AceFlags;
public UInt32 AceType;
public string GuidInheritedObjectType;
public string GuidObjectType;
public Trustee Trustee;
};
public class Trustee
{
public string Domain;
public string Name;
public UInt16[] SID;
public UInt32 SidLength;
public string SIDString;
};
It returns nothing. The list object is empty. I am definitely doing something wrong. Can some one please help me out?