LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 17-Sep-2009, 07:35 PM
Junior Member
 
Join Date: Sep 2009
Posts: 8
KaranMahant 0 reputation points
Default Re: reading objectGuid into System.Guid

This is what I am doing. It seems to work alright
Code:
		public static Guid GetGuid(this LdapEntry entry)
		{
			try
			{
				LdapAttribute guidAttr = entry.getAttribute("GUID");

				if (guidAttr != null && guidAttr.StringValue.Length != 0)
				{
					byte[] bGuid = new byte[8];
					for (int i = 0; i < 8; i++)
					{
						bGuid[i] = (byte)guidAttr.ByteValue[i];
					}

					Guid guid = new Guid(
							BitConverter.ToInt32(bGuid, 0),
							BitConverter.ToInt16(bGuid, 4),
							BitConverter.ToInt16(bGuid, 6),
							(byte)guidAttr.ByteValue[8],
							(byte)guidAttr.ByteValue[9],
							(byte)guidAttr.ByteValue[10],
							(byte)guidAttr.ByteValue[11],
							(byte)guidAttr.ByteValue[12],
							(byte)guidAttr.ByteValue[13],
							(byte)guidAttr.ByteValue[14],
							(byte)guidAttr.ByteValue[15]);

					return guid;
				}
				else
				{
					App.Log.Error(App.AppResources.Strings.FormatString("NovellDirectoryAttributeReadFailed", "Guid", entry.DN));
					App.Log.Trace("Exception in NovellDirectoryProvider: Error in reading Guid attribute for {0}", entry.DN);
					throw new DirectoryException(DirectoryErrorCodes.MandatoryAttributeReadFailed, App.AppResources.Strings.FormatString("NovellDirectoryAttributeReadFailed", "Guid", entry.DN));
				}
			}
			catch (LdapException x)
			{
			}
			catch (Exception x)
			{}
		}
Reply With Quote
 

Tags
byte, csharp, guid, ldap, sbyte

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -6. The time now is 08:40 PM.


© 2007 Novell, Inc. All Rights Reserved.

Search Engine Friendly URLs by vBSEO 3.3.0 RC2