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