_pulsar_: OpenHUG Meeting, wir freuen uns auf zahlreiches Erscheinen! http://linkd.in/drEaBF || http://bit.ly/aERlUU || http://bit.ly/bNGGCt - _pulsar_: OpenHUG Meeting, wir freuen uns auf zahlreiches Erscheinen! http://linkd.in/drEaBF || http://bit.ly/aERlUU || http://bit.ly/bNGGCt [/me Twitters]
While fighting some more problems with Sharepoint 2007 Variations "System" I had to write this comment in my code today:
// note: there is a bug in Sharepoint 2007 when using ", " within a page name - "foo, bar.aspx" for instance. // note: This will render the relationship list entry useless. A healthy object id attribute in a // note: relationship list's entry looks like this: // note: ows_ObjectID='http://mucskysp04:4711/DE/Seiten/Seite mit Sönderzeichen.aspx, /DE/Seiten/Seite mit Sönderzeichen.aspx' // note: once "broken" using the naming-"exploit", the relationship will be represented as: // note: ows_ObjectID='http://mucskysp04:4711/DE/Seiten/variationsseite, mitkommaundleerzeichen.aspx' // note: note the missing relative path. There is no reason to work around this bug in this tool since the original // note: entry in Sharepoint won't be functional anyway (no entries will be shown in the variations dropdown)
public static IDictionary<RequestTypeEnum, RequestGroupEnum> { {RequestTypeEnum.RegisterAccount, RequestGroupEnum.Account}, {RequestTypeEnum.UnregisterAccount, RequestGroupEnum.Account}, {RequestTypeEnum.RegisterInetAccess, RequestGroupEnum.InetAccess}, {RequestTypeEnum.UnregisterInetAccess, RequestGroupEnum.InetAccess}, {RequestTypeEnum.RegisterMailbox, RequestGroupEnum.Mailbox}, {RequestTypeEnum.UnregisterMailbox, RequestGroupEnum.Mailbox}, {RequestTypeEnum.RegisterRLA, RequestGroupEnum.RLA}, {RequestTypeEnum.UnregisterRLA, RequestGroupEnum.RLA} };
Yesterday I was implementing a generic serializer (for logging purposes). While there is a good number of XML serializers available for .NET - none of them was meant to be used for only the purpose of reading. That means, I would not need deserialization but only some nice human readable output.
Anyway, thats not the point here. What took me about an hour to figure out is how to handle arrays (of natives) via reflection. I kinda feel stupid, but let me show you what i tired:
Object propertyValue = prop.GetValue(o, null); if (propertyValue != null && propertyValue.GetType().IsArray) { //if you need the type, here is how we get it, it's not used //in this example. Type arrayType = propertyValue.GetType().GetElementType(); object[] arr = propertyValue as object[]; for (int i = 0; i < arr.Length; i++) { // serialization logic goes here } } ...
While this might work perfectly for arrays of "real" objects such as string[] - it will fail when your array is composed of native objects such as long[]. The cast to object[] will get you a nice null reference. Yummy.
After that I've been looking for Array.ForEach() which was pretty interesting, but did not really help due to it's generic nature. The solution was much simpler in the end, it just did not cross my mind to cast the propertyValue to Array - sometimes .NET can be pretty mysterious in terms of Autoboxing. Here is how it should be done:
Object propertyValue = prop.GetValue(o, null); if (propertyValue != null && propertyValue.GetType().IsArray) { Array array = propertyValue as Array; foreach (var arrElement in array) { // serialization logic goes here } } ...
Straight forward, simple - makes me feel stupid.
layoutTable.Rows.Add ( ControlUtils.CreateRow ( EmployeeFieldLabels.ExternalCompanyName, { AllowMultipleSelection = false, RenderListHeader = false, CountryProviderId = locationPickerControl.ID, CountryProviderProperty = "SelectedCountryIsoCode"; }, false, EmployeeFieldTooltips.ExternalCompanyName, Page, CreateChildID("ExternalCompanyLabel"), ( externalCompanyValidator = new CompareValidator { ControlToValidate = CreateChildID("ExternalCompanyName"), Operator = ValidationCompareOperator.Equal, Type = ValidationDataType.Integer, ValueToCompare = "1", EnableClientScript = false, Display = ValidatorDisplay.Dynamic, ErrorMessage = string.Format(EmployeeManagerControlRes.ErrorValueRequired, EmployeeFieldLabels.ExternalCompanyName) } ) ) );
Check them out! http://msdn.microsoft.com/en-us/library/bb384062.aspx
The last 2 days I've been working on a concept paper for a project. One aspect covers user management using an active directory.
At the first glance, everything looks easy. One would think AD is just another LDAP server - no worries here. It turns out, AD has a lot of hidden constraints and expect you do things a certain way. For instance, if you want to add a user to a specific group, you are not going to update the user's "memberOf" LDAP attribute. This is read only; you will need to add that user to the group LDAP node. This is just one and quite straight forward example how AD can be a pain in the arse if you have no idea about the internals.
Luckily the guys over at http://en.csharp-online.net/ have assembled a damn good article about all daily tasks you will encounter if you are going to automate some user administration tasks using the Active Directory as your backend. Head over here: http://en.csharp-online.net/User_Management_with_Active_Directory%E2%80%...
I have also stumbled across a wrapper library which abstracts all the LDAP / DirectoryEntry specific calls and focuses on user- and group-centric API: http://www.dotnetactivedirectory.com/ - I have no idea yet if this one is good or not, I guess I will find out soon since I plan to cut down the development times by 2 Days and use this API instead.
update
After looking into the free (lite) version of .NET Active Directory wrapper, I am not so sure about purchasing a license anymore. 400 or 1000 bucks a a pretty hefty price tag for a software not being in development anymore (as it seems, last update 2007) and consisting only from one pseudo class. It can hanlde only one AD connection due to static (!) fields for login and password. Furthermore it does not persist a connection to the AD but re-creates a new Directry Entry with each operation - now do some mass operations on say... 5k users by assigning them to a AD groups or something. I suppose it will be still more expensive for the project for me to code the mini-api, but after considering those facts, I might be better off. Especially when it comes to multiple AD servers and support requests I might get for this particular module. Geez! Where do ppl learn coding!? I guess good marketing and price tags not reflecting the code quality can still compensate it
If you are into Sharepoint-Development you will appreciate the STSADM Custom Extensions made by Gary Lapointe: http://stsadm.blogspot.com/2007/08/stsadm-commands_09.html
In our case they saved us a lot of troubles we had when moving a Sharepoint Site Collection to a new server while preserving the Variations which have been created before.
One of the commands we have been toying with was "gl-fixvariationrelationships". Since the sources to all of these extensions are available to download for free, I could even get this one working for a Variation root other than "/" by modifying the sources a tiny bit. If you run into the same situation feel free to grab my Version of the FixVariationRelationships Class over here or here (can't get drupal to ignore HTML validation for Geshi-Nodes editing)
OutlookFolderExporter 0.3 Beta
What does it do?
Export an Outlook folder containing E-Mail Messages to a physical filesystem folder. Message by message.
Requirements?
Why?
Someone asked me if I knew a tool or a way to do this. From what I understand he was about to share such messages using a Windows-Share. I know there are better ways to achieve this, provided you are using an Exchange-Server - but for some reason it did not work out for them.
Limitations?
Plenty, this is a really quick hack:

License?
Public domain, check the "License.txt" in the sources package for further details.
History
0.3 Beta: 2008-07-02 20:40 0.3
0.2 Alpha 2008-07-02 14:00 - 0.2
Download?
Sometimes I do really wonder why some great tools remain silent and hidden from the public for such a long time. The guys over at codeproject featured an article about the "TraceTool". Describing it with "yet another log viewer" won't do any justice. Just head over to the article and glance over it. It's able to interface with the most common logging frameworks such as .NET's native, log4net/log4j, NT System Evenlog and plain files.
I must admit I did not try it yet. Will do next week when I'm back in the office - I don't really feel like I want to be coding this weekend. But just reading the specs and howtos on the codeproject site blew my mind. Looks like a jewel, smells like a jewel... might be one!