Thursday, 18 August 2016

  • Assigning File Share permissions using Power Shell more...
  • Managing File Shares with Windows PowerShell more...
 

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;
}



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();
}


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)



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