Thursday, April 27, 2017

wpf datagrid simple bind

<Window x:Class="ldapTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ldapTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
        <StackPanel>
            <DataGrid Name="grid1"></DataGrid>
        </StackPanel>
</Window>


        public MainWindow()
        {
            InitializeComponent();
            grid1.ItemsSource = new ObservableCollection<MyData>()
                                    {
                                        new MyData("x@y.z", "my1"),
                                        new MyData("m2@a.b","my2")
                                    };
           
        }


        public class MyData
        {
            public string Email { get; set; }
            public string Name { get; set; }

            public MyData(string email, string name)
            {
                Email = email;
                Name = name;
            }
        }

Wednesday, April 26, 2017

ldap basics

aus https://de.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol:

" Ein einzelnes Objekt wird eindeutig durch den Distinguished Name (DN) identifiziert, wie zum Beispiel uid=juser,ou=People,ou=webdesign,c=de,o=acme. Dieser setzt sich aus einzelnen Relative Distinguished Names (RDN) zusammen. Eine andere Schreibweise für den DN ist der canonical name, der keine Attribut-Tags wie ou oder c enthält und bei dem die Trennung zwischen den RDNs durch Schrägstriche erfolgt. Außerdem beginnt die Reihenfolge, im Gegensatz zum dn, mit dem obersten Eintrag, also zum Beispiel acme/de/webdesign/People/juser."





down voteaccepted
  • CN = Common Name
  • OU = Organizational Unit
  • DC = Domain Component
  • O = Organiszation

Tuesday, April 25, 2017

ldap query c#

using public ldap test server:

            DirectoryEntry rootEntry = new DirectoryEntry("LDAP://ldap.forumsys.com/cn=read-only-admin,dc=example,dc=com");
            rootEntry.AuthenticationType = AuthenticationTypes.None; //Or whatever it need be
            DirectorySearcher searcher = new DirectorySearcher(rootEntry);
            var queryFormat = "(&(objectClass=user)(objectCategory=person)(|(SAMAccountName=*{0}*)(cn=*{0}*)(gn=*{0}*)(sn=*{0}*)(email=*{0}*)))";
            //TODO searcher.Filter = string.Format(queryFormat, "michael");
            foreach (SearchResult result in searcher.FindAll())
            {
                Console.WriteLine("account name: {0}", result.Properties["samaccountname"].Count > 0 ? result.Properties["samaccountname"][0] : string.Empty);
                Console.WriteLine("common name: {0}", result.Properties["cn"].Count > 0 ? result.Properties["cn"][0] : string.Empty);
            }


read all props:
            var rootEntry = new DirectoryEntry("LDAP://ldap.forumsys.com/cn=read-only-admin,dc=example,dc=com");
            rootEntry.AuthenticationType = AuthenticationTypes.None; //Or whatever it need be
            var searcher = new DirectorySearcher(rootEntry);
            //var queryFormat = "(&(objectClass=user)(objectCategory=person)(|(SAMAccountName=*{0}*)(cn=*{0}*)(gn=*{0}*)(sn=*{0}*)(email=*{0}*)))";
            //TODO searcher.Filter = string.Format(queryFormat, "michael");
            foreach (SearchResult result in searcher.FindAll())
            {
                foreach (var propertyName in result.Properties.PropertyNames)
                {
                    StringBuilder sb = new StringBuilder();
                    string sPropName = propertyName?.ToString();
                    if (!string.IsNullOrEmpty(sPropName))
                    {
                        sb.Append(sPropName + ":");
                        var vals = result.Properties[sPropName];
                        foreach (var val in vals)
                        {
                            sb.Append(val);
                        }

                        Console.WriteLine(sb);
                    }

                }
                Console.WriteLine("-------------------------------------------------------");
            }

Wednesday, April 19, 2017

c# format Timespan

string s = String.Format("{0} {1:00}:{2:00}:{3:00}", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);

linux rasperry pi rrdtool

erzeuge rrd db beispiel:


echo "Erzeuge rrd Datenbank fuer 3 Werte (Temp, Luftdruck und Höhe), 100 Tage aufbewahrung viertelstuendlicher AVG  100 Jahre aufbewahrung min /max / avg"

#step 900 sec (60*15=900) alle viiertelstunden
#DS Datasource:name:GAUGE:heartbeat 20min=1200sec:min::max
#RRA RoundRobinArchive alle 9600 Zeilen (pro Tag 96 Zeilen (=24*4)
# 100 Jahre aufbewahrung min, max, AVG

rrdtool create bmp.rrd --step 900 \
DS:t0:GAUGE:1200:-50:200 \
DS:t1:GAUGE:1200:-50:200 \
DS:t2:GAUGE:1200:-50:200 \
RRA:AVERAGE:0.5:1:9600 \
RRA:MIN:0.5:96:36000 \
RRA:MAX:0.5:96:36000 \
RRA:AVERAGE:0.5:96:36000




zeige letzten eintrag in db an:

rrdtool  lastupdate bmp.rrd

https://www.epochconverter.com/ rechnet unix timestamp in datum/zeit um

erzeuge Graph


rrdtool graph tempweek.png \
  -s 'now - 1 week' -e 'now' \
  DEF:temp0=temperature.rrd:temp0:AVERAGE \
  LINE2:temp0#00FF00:Innen \
  DEF:temp1=temperature.rrd:temp1:AVERAGE \
  LINE2:temp1#0000FF:Außen

rrdtool graph temperaturDay.png \
  -s 'now - 1 day' -e 'now' \
  DEF:temp0=temperature.rrd:temp0:AVERAGE \
  LINE2:temp0#00FF00:Innen \
  DEF:temp1=temperature.rrd:temp1:AVERAGE \
  LINE2:temp1#0000FF:Außen

Sunday, April 16, 2017

webserver iis leerlaufzeit (idle time) anwendungspool

in erweiterte eigenschaften des anwendungspoll läßt sich die webserver iis leerlaufzeit (idle time) einstellen, damit eine webseite schneller reagiert (nicht so lange zum Laden braucht) nachdem sie längere Zeit nicht genutzt wurde

Tuesday, April 11, 2017

git basics

basic workflow

Get bzw Checkout - from server to local repro

git config --list //list
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

git clone https://github.com/username/reproname.git localDirName //get repro
git status //show changes
git log  //show last commits
git cherry -v //show commits needed to push

git fetch
git pull

anzeigen orgiginal url
git remote -v oder git config --get remote.origin.url.

push / checkin - from local to server

git add -A //stage changes

git commit -m "message"
ändern:
git commit --amend
git commit --amend -m "New commit message"
revert initial commit: git update-ref -d HEAD
git push

Revert

git checkout Dateiname

Stash

git stash list
git stash
git stash drop 1

Branches

switch to branch: git checkout branchname

https://git-scm.com/book/de/v1/Git-Branching-Einfaches-Branching-und-Merging

list all: git branch -a
list local: git branch -r
create: git branch myNewBranchName



merge:
git checkout destinationBranch (eg. master)
git merge branch (e.g. hotfix)
git branch -d hotfix //löschen

rebase:
git rebase -i HEAD~2

letzte 2 commits zusammenführen, es öffnet sich Editor, squash vor den commit schreiben den man "entfernen" will


Special

suda apt-get install git
git init --bare

git init
git remote -v
git remote add 




Git Atlassian Source Tree Basics

shows all commits in one timeline

get: clone / new (from server to local repro and files)
commit => files to local repro
push => from local repro to server


Wednesday, April 05, 2017

javascript basics

display hello msg:
<button onclick="alert('Hallo!')" >Hallo </button>

Monday, April 03, 2017

update Asp.Net USer Db

doesn't help:

ALTER TABLE [dbo].[AspNetUsers] add [Email] [nvarchar](256) NULL
ALTER TABLE [dbo].[AspNetUsers] add [EmailConfirmed] [bit] NOT NULL DEFAULT (0)
ALTER TABLE [dbo].[AspNetUsers] add [PhoneNumber] [nvarchar](max) NULL
ALTER TABLE [dbo].[AspNetUsers] add [PhoneNumberConfirmed] [bit] NOT NULL DEFAULT (0)
ALTER TABLE [dbo].[AspNetUsers] add [TwoFactorEnabled] [bit] NOT NULL DEFAULT (0)
ALTER TABLE [dbo].[AspNetUsers] add [LockoutEndDateUtc] [datetime] NULL
ALTER TABLE [dbo].[AspNetUsers] add [LockoutEnabled] [bit] NOT NULL DEFAULT (0)
ALTER TABLE [dbo].[AspNetUsers] add [AccessFailedCount] [int] NOT NULL DEFAULT (0)


f

Saturday, April 01, 2017

enable telnet

dism /online /Enable-Feature /FeatureName:TelnetClient

register wcf asp.net on iis

before: ASPNET_REGIIS /I
now: dism /online /enable-feature /featurename:IIS-ASPNET45 /all


Friday, March 31, 2017

Web Projects in Visual Studio 2015

have moved from new projects to File / New Web Site

x86 or x64 - DUMPBIN dllname.dll /Headers

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64_x86

Monday, March 27, 2017

bat datei log date time

echo Begin >ExecAnalyticsDataReportingLog.txt
Date /T >>ExecAnalyticsDataReportingLog.txt
TIME /T >>ExecAnalyticsDataReportingLog.txt
sqlcmd -S localhost\sqlexpress -D StpDb -Q "exec mySP"
echo Finish >>ExecAnalyticsDataReportingLog.txt
Date /T >>ExecAnalyticsDataReportingLog.txt
TIME /T >>ExecAnalyticsDataReportingLog.txt

Tuesday, March 21, 2017

osmc samba (linux)

prüfen ob installiert:
ps -ef |grep smb
sollte eine oder mehre zeile mit /usr/sbin/smbd liefern


install:
sudo apt-get install samba

adduser peter
smbpasswd -a peter


/etc/smb.conf

[freigabename]
path = /srv/data
wrtiteable = yes
valid users = peter



neustart:
sudo systemctl restart smbd.service



https://wiki.ubuntuusers.de/Samba_Server/

sudo smbpasswd -a <username> # Fügt den Benutzer <username> der Samba Datenbank hinzu und aktiviert diesen
sudo smbpasswd -x <username> # Entfernt den Benutzer <username> aus der Samba Datenbank
sudo smbpasswd -d <username> # Deaktiviert den Benutzer <username> in der Datenbank
sudo smbpasswd -e <username> # Aktiviert den vorher deaktivierten Benutzer <username> in der Datenbank wieder 


Wednesday, March 15, 2017

signing assembly strong name / signtool

A) STRONG NAME

1) you need SDK Tool SN:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\sn.exe

2) create key file:
sn -k StrongNameKeyFile.snk

3) sign the assembly in Visual Studio
in VisualStudio open Project Properties,
Signing,
Sign the assembly and choose the StrongNameKeyFile.snk from (2)

4) check if assembly is strong named:
sn -v assembly name
=> output ....exe stellt keine Assembly mit einem starken Namen dar.
oder
=> output Die Assembly "....exe" ist gültig

readmore:
https://www.linkedin.com/pulse/code-signing-visual-studio-jason-brower

B) SIGNTOOL

C:\Program Files (x86)\Windows Kits\10\bin\x64

/a automatically selects the code signing certificate with the longest valid date:
signtool sign /a yourApp.exe 
=> output Done Adding Additional Store 
Succeddfully signed: yourapp.exe

=> there is a new Tab in Windows File Properties named "Digital Certificates" which shows the cert owner

buildtarget and BadImageFormatException

http://stackoverflow.com/questions/5229768/c-sharp-compiling-for-32-64-bit-or-for-any-cpu


On a 32-bit machine:

  • Any CPU: runs as a 32-bit process, can load Any CPU and x86 assemblies, will get BadImageFormatException if it tries to load an x64 assembly.
  • x86: same as Any CPU.
  • x64: BadImageFormatException always.

On a 64-bit machine:

  • Any CPU: runs as a 64-bit process, can load Any CPU and x64 assemblies, will get BadImageFormatException if it tries to load an x86 assembly.
  • x86: runs as a 32-bit process, can load Any CPU and x86 assemblies, will get BadImageFormatException if it tries to load an x64 assembly.
  • x64: same as Any CPU.
It is the JIT compiler that generates an assembly code that's compatible with the requested target based on this flag.

Tuesday, March 14, 2017

code signing certificate

StartCom:
easy: upload documents, wait 1 day for validation
comodo (and resellers): have to go to notary and send letter to usa

Saturday, March 11, 2017

UEFI New Boot drive


https://forum.acronis.com/forum/25975

On a Dell Latitude I had to go into the BIOS settings under boot sequence. Then under the UEFI settings it will show the Windows Boot for the old hard drive. It seems to be tied to the serial of the drive. If you click on add new, it will populate with the cloned drive serial, you simply just give it a name (I called it Windows New) and copy the boot location from the existing entry (bottom line). The EFI files it needs to boot with are stored in a hidden partition on the drive (which also much be cloned) - this is what you are pointing to.