November 2005 - Posts
|
I have been wondering how to use that crappy Traffic jams
and the hell load of time one has on the crowded roads of Bangalore
when commuting to office. Well with this in mind I finally picked up a
few new episodes onto my PPC and made it a point to watch them rather than
be bothered about the damn road blocks and traffic. Tonight's
show - WinFX at PDC |
|
After a lot of digging and findings on the LSA API, one would usually give
up. Now in the managed world one would obviously jump looking to
DirectoryServices for help but then after quite a lot of poking around i
realized only the userFlags (winNt ) could be set and the policy object is
totally in a different direction. Well then finally LSA was suggested as the way
to go.
There was this wonderful article on code project that I found quite usefull
in giving a good understanding of the API by Corinna John http://www.codeproject.com/csharp/lsadotnet.asphttp://www.codeproject.com/csharp/lsadotnet.asp
Now the program here had a few gliches which im not too sure why.
So i went
around looking a bit more and there to the resuce was pinvoke.net. Check this
article out at http://pinvoke.net/default.aspx/advapi32/LsaOpenPolicy.htmlhttp://pinvoke.net/default.aspx/advapi32/LsaOpenPolicy.html
This too follows from the code project article.
The most interesting part in
sample at pinvoke.net was the use of the custom marshaler for the
LSA_UNICODE_STRING which turn out to be known as the super special lsa string.
Ok if you just want to dive into LSA here is the way to go http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/lsaopenpolicy.asphttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/lsaopenpolicy.asp
Consider a
method definition as follows
public void Write(object val);
You can call the
method simply like this
MyConsole.Write(100);
It works fine provided
this happens in a language like C# where primitive types are boxed automatically.
Looking at IL this is how it disassembles
IL_0000:
ldc.i4.s 100
IL_0002:
box [mscorlib]System.Int32
IL_0007:
call void
Writer.MyConsole::Write(object)
As you can see it just
simply boxes it up into an Int32 struct.
In J# you get the
following error if you use the above statement to call the
method.
c:\Code\JSharpInt\JSharpInt\Class1.jsl(12):
Cannot find method 'Write(int)' in
'Writer.MyConsole'
Now you need
to box this explicitly if you are sure of the method, using the Int32
struct.
J#
Writer.MyConsole.Write((System.Int32)10);
Well you can check out
the IL
IL_000c:
ldc.i4.s 10
IL_000e:
box [mscorlib]System.Int32
IL_0013:
call void
[Writer]Writer.MyConsole::Write(object)
This is one awesome feature I liked about Community Server 2.0

XML serialization and deserialization is one interesting topic. I came across
some interesting conversations when there was a requirement as to enable input
values that are culture specific.
I would say XML is gotta be kept culture
independed, always think about the consumer. Also we would always prefer this to
happen across culture and also across versions.
So why make it culture
specific?
Well I guess this is pretty evident from the way the framework
implements XML serialization.
What ever the culture may be on the thread the
way the xml serialization takes place is kind simple and straight forward.
de-DE
1,001 <?xml
version="1.0"
encoding="utf-16"?><decimal>1.001</decimal>
If you want to see it your self here it the snippet.
1 private string DisplayAllCultures()
2 {
3 decimal val = 1.001M;
4
5 StringBuilder result = new StringBuilder();
6 foreach(CultureInfo ci in CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures))
7 {
8 Thread.CurrentThread.CurrentCulture = ci;
9
10
11 result.Append(ci.Name);
12 result.Append(" ");
13 result.Append(val.ToString());
14 result.Append(" ");
15
16 using(MemoryStream mem = new MemoryStream(200))
17 {
18 //Read the serialzed string from memory
19 XmlTextWriter writer = new XmlTextWriter(mem,Encoding.Unicode);
20 XmlSerializer xs = new XmlSerializer(typeof(decimal));
21 xs.Serialize(writer,val);
22
23 mem.Position = 0;
24 byte[] buffer = new byte[mem.Length];
25 mem.Read(buffer,0,Convert.ToInt32(mem.Length -1));
26 UnicodeEncoding unicode = new UnicodeEncoding();
27 result.Append(unicode.GetChars(buffer));
28 }
29
30 result.Append("\r\n");
31 }
32 return result.ToString();
33 }
34
I was kind of surprised when I got a mail asking me if i would review the a Tangible Architect and was happy to.
Anyway more importantly I have always been playing around with Olymars and now its time really do some stuff.
I've also been working with EntityBroker for quite a while.
Lets see how this baby comes out. :)