“No problem can be solved from the same level of consciousness that created it.” Albert Einstein (1879-1955)
Monday, 29 August 2016
Monday, 8 August 2016
Hiding a Mailbox from the Global Address List with Directory Syncronization Enabled
Hiding and/or un-hiding a mailbox from the Global Address List (GAL) when Directory Syncronization is enabled, is a bit tricky. To know how to hide/un-hide mailbox from GAL, follow this article more...
Saturday, 23 July 2016
C# Active Directory Get Account Status
public static bool GetAccountStatus(string alias, string property)
{
UserPrincipal user = UserPrincipal.FindByIdentity(GetPrincipalContext(), IdentityType.SamAccountName, alias);
DirectoryEntry directoryEntry = user.GetUnderlyingObject() as DirectoryEntry;
bool value = null;
switch (property.ToLower())
{
case "enabled":
value = (user.Enabled == true);
break;
case "accountexpire":
value = user.AccountExpirationDate() < DateTime.Now;
break;
case "passwordneverexpires":
value = (user.PasswordNeverExpires == true);
break;
}
return value;
}
{
UserPrincipal user = UserPrincipal.FindByIdentity(GetPrincipalContext(), IdentityType.SamAccountName, alias);
DirectoryEntry directoryEntry = user.GetUnderlyingObject() as DirectoryEntry;
bool value = null;
switch (property.ToLower())
{
case "enabled":
value = (user.Enabled == true);
break;
case "accountexpire":
value = user.AccountExpirationDate() < DateTime.Now;
break;
case "passwordneverexpires":
value = (user.PasswordNeverExpires == true);
break;
}
return value;
}
C# Retrieve Get Directory User Attributes
UserPrincipal user = UserPrincipal.FindByIdentity(GetPrincipalContext(), IdentityType.SamAccountName, alias);
if (user != null)
{
DirectoryEntry directoryEntry = (user.GetUnderlyingObject() as DirectoryEntry);
DirectorySearcher adSearch = new DirectorySearcher(directoryEntry);
adSearch.SearchScope = SearchScope.Subtree;
adSearch.Filter = "(&(ObjectClass=user)(sAMAccountName=" + alias + "))";
SearchResult sResult = adSearch.FindOne();
if (sResult.Properties.Contains(attribute))
propertyValue = sResult.Properties[attribute][0].ToString();
}
if (user != null)
{
DirectoryEntry directoryEntry = (user.GetUnderlyingObject() as DirectoryEntry);
DirectorySearcher adSearch = new DirectorySearcher(directoryEntry);
adSearch.SearchScope = SearchScope.Subtree;
adSearch.Filter = "(&(ObjectClass=user)(sAMAccountName=" + alias + "))";
SearchResult sResult = adSearch.FindOne();
if (sResult.Properties.Contains(attribute))
propertyValue = sResult.Properties[attribute][0].ToString();
}
Wednesday, 15 June 2016
Monday, 16 May 2016
Run a C# .cs file from a Powershell Script
$source =
@"
public class BasicTest
{
public static int Add(int a, int b) {
return (a + b);
}
public int Multiply(int a, int b) {
return (a * b);
}
}
"@
# type definition - must be declared
Add-Type -TypeDefinition $source
# access a static method
[BasicTest]::Add(4, 3)
# create instance of class and call a non-static method
$basicTestObject = New-Object BasicTest
$basicTestObject.Multiply(5, 2)
@"
public class BasicTest
{
public static int Add(int a, int b) {
return (a + b);
}
public int Multiply(int a, int b) {
return (a * b);
}
}
"@
# type definition - must be declared
Add-Type -TypeDefinition $source
# access a static method
[BasicTest]::Add(4, 3)
# create instance of class and call a non-static method
$basicTestObject = New-Object BasicTest
$basicTestObject.Multiply(5, 2)
Subscribe to:
Posts (Atom)
Analysis Service in Power BI Report Server
We couldn’t connect to the Analysis Services server. Make sure you’ve entered the connection string correctly... link
-
//convert BASE64 string to Byte{} array function base64ToArrayBuffer(base64) { var binaryString = window.atob(base64); var binar...
-
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter(); htmlToPdf.PageFooterHtml = @"<div style='text-align:right; font-s...
-
static void Main(string[] args) { // create a dummy list List<string> data = GetTheListOfData(); // split the lis...