Sunday, May 3, 2009

Business logic and the Entity Framework

I wrote a small article on CodeProject, with a sample project to dabble in. Check it out here: http://www.codeproject.com/KB/linq/entity_interceptors.aspx and let me know if you liked it!

Friday, December 19, 2008

Sharp (#) Problem :)

Hiya all,

my holidays just started... weeeeeeeeeeeeeeeeeeeeeee... and ran head on into a problem with the stupid *.chm files I got myself from work (yeah yeah yeah... holidays and such, I know).

Buuut... none of these things would open, displaying a nasty 'Page cannot be displayed' on the right hand side of the window.
Now there are quite a few solutions to this, of which none worked.. always got that dreaded IE comment about my *.chm... rats.

Though, on a lonely site in the MS databases if found an interesting, yet vital fact... listen up people, there's going to be a test :)

IF the path to the CHM contains a '#' it won't display.

Now imagine my path: 'C:\Data\AD-Migration\C#\Tools\GroupBouncer\Help'... great

Exchanged every occurence of '#' with 'Sharp' (using a quick-hack-prog in CSharp :) ) and BEHOLD THE EMPEROR'S NEW... *looks at scroll again*... errrrr... OLD CHM's!

I hope I at least save somebody's time with this little note... drop me a line... or a beer... well.... thinking that over... AND a beer :)

Regards,
Dirk

Starting to fiddle with LINQ... I think...

Thursday, November 13, 2008

License and Registration, please

As promised the next post is here... this time about checking Groupmembership in a logonscript using VBS.

First of all I have to say this is not the most flexible way of doing it, especially if you have a few different domains to check for, but it should give you a lead on 'how-to'.

  1. Option Explicit

  2. On Error Resume Next

  3. Dim oWS : Set oWS = WScript.CreateObject("WScript.Shell")
  4. Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
  5. Dim oWN : Set oWN = CreateObject("Wscript.Network")

  6. Const ADS_SCOPE_SUBTREE = 2
  7. Set objConnection = CreateObject("ADODB.Connection")
  8. Set objCommand = CreateObject("ADODB.Command")
  9. objConnection.Provider = "ADsDSOObject"
  10. objConnection.Open "Active Directory Provider"

  11. Set objCommand.ActiveConnection = objConnection
  12. objCommand.Properties("Page Size") = 1000
  13. objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

  14. objCommand.CommandText = "Select ADsPath, Name From 'LDAP://dc=my,dc=domain,dc=com' Where objectCategory = 'Group' AND Name='AD-Migration'"
  15. Set objRecordSet = objCommand.Execute
  16. objRecordSet.MoveFirst
  17. Set objGroup = GetObject(objRecordSet.Fields("ADsPath").Value)

  18. Dim UserInGroup
  19. UserInGroup=False

  20. For Each strUser in objGroup.Member
  21. set objUser=GetObject("LDAP://"+struser)

  22. if (LCase(objUser.samaccountname)=LCase(oWN.UserName)) then
  23. UserInGroup=True
  24. end if
  25. Next

  26. if(UserInGroup=True)then
  27. oWS.Run("wscript.exe .\AD_UserProfileMigration\migrate_station.vbs")
  28. else
  29. Wscript.Quit(0)
  30. end if
Actually pretty straigtforward. The only thing that cost me quite some time is the fact that the contents of the 'UserObject' are referenced by a '.' and the 'RecordSet' uses 'Field()'. That threw me off track and was one of the main points of cursing :)

I'll just assume you know your programming bits and go on from top to bottom:
Create default objects for Filesystem, Scriptshell and Network. Though I do not need all of them in this one, the main logonscript has all of those in use. So I just included them here too.

Next thing we do is setting up a query for LDAP to our domain where we look for the specific group 'AD-Migration'. All members of that group have to be migrated to the new Domain.
The beauty of this is that you can stuff a new member in there on the On-Site-DC and the change is immideatly done.. no relog.. no gpupdate... just restart the script.

Next step is to interate through all members and see if their current logonname matches the logonname in the group. Next Gotcha... MS calls this 'SamAccountName' in the AD-Schema. And... great praise to whoever dreamed that up... the description in the schema is... *drumroll* 'SamAccountName' DUH...

So... we set a boolean to 'true' if we found the name and start the script(s) accordingly... no magic there...

I hope this did help you a bit on your way... I have some recommended reading though:
  • The windows script Help (v5.6 at the moment). Won't link it here, because it is likely to change in URL. Just search on MS.com.
  • Windows Server Support Tools. These bring the 'Active Directory Schema' Add-In for the Managementconsole
With these two things and a bit of fiddling I am sure you'll handle some of the more advanced thingies that will cross your way. I am still on my quest for less fuss for the user and will surely try to blog my cur... thoughts here :)

Questions welcome :)

See you soon,
Dirk

P.S.:
Yes, actual workingcode directly from our logonscript. I works, honestly!

Thursday, November 6, 2008

Long time no C[++,#]

Busy, busy, busy... and still am :)

Recently we were merging our domain(s) to one, big domain... which is not easy when the impact for the users should be zero (best case that is).

So, what did I learn?
First and foremost VBS *shiver* for the logonscripts and other neato thingies that needed to be done while the user cannot do much about them... which is most important, as these pesky people tend to stop whatever is running just to get to their 'Lotus Notes'.

Second... I did not find a way to make a simple, standalone program to set various (temporary) rights for the users in C#. And I *tried*... HARD... which brought me back to my trusty (and rusty) C++ Builder (I *hate* that registration process thing, Borland! And I *hate* the new help, get the old one back... much niiiicer)

Third... don't trust MS with their docs either... I found a few very *wrong* things they put into the Active Directory Schema docs... well... the Domain will recover :)

What is to expect next from me?
Weeeeeeell... a few posts with tips on what to do and what THE HECK NOT to do in Domainmigration, some neato things I got hopping in VBS (in your *face* Central Team! I *did* get it working, noobs), a neato thing discovered in C# (Yes, Kurt, still fiddling with it and not abandoned) and general riffraff I need to get out :)

There were some questions about me abandoning the blog... yeah... riiiight.

So... I try to post more regularly and keep you updated :)

Thursday, August 28, 2008

RSS/ATOM feed extensions made easy

The easiest way to add custom elements to a syndicated (ATOM/RSS feed) is to use an XElement, like this:

SyndicationFeed feed = new SyndicationFeed("FeedName", "Feed description");

//fill feed with items (omitted)

XNamespace ns = "http://tempuri.org/myapp";

feed.ElementExtensions.Add(new XElement(ns + "myCustomProperty", "hello"));

return new Atom10FeedFormatter(feed) // to return as an atom feed


Happy feeding!

Wednesday, August 6, 2008

70-561 bookable

You can now book for 70-561. ADO.NET 3.5. Wich is what i'll do this week.