473,564 Members | 2,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading System.Byte[] Value from AD

Hi all,

I am writng some code to read AD user properties but I am not having much
luck reading octet values. For example, there is a property userPassword
which returns System.Byte[].

When I use ADSIEDIT, I can see the value in the format 0x077 0x043 0x064
0x055 0x072 0x054 0x44 0x058 which I can convert by using Character Map.

Does anyone know how I can get the value of this property.

Regards,

Pere

PS: I am very new to C#

Jun 17 '06 #1
4 3664
Hi Pere,

System.Text.Enc oding.Default.G etString(bytes) ;

You can replace "Default" with any of ASCII, UTF32, UTF8, UTF7, Unicode and
BigEndianUnicod e if you'd like to match the appropriate encoding.

HTH

"Pere Raphael" <Pe**@community .nospam> wrote in message
news:uY******** ******@TK2MSFTN GP03.phx.gbl...
Hi all,

I am writng some code to read AD user properties but I am not having much
luck reading octet values. For example, there is a property userPassword
which returns System.Byte[].

When I use ADSIEDIT, I can see the value in the format 0x077 0x043 0x064
0x055 0x072 0x054 0x44 0x058 which I can convert by using Character Map.

Does anyone know how I can get the value of this property.

Regards,

Pere

PS: I am very new to C#

Jun 17 '06 #2
Hi Dave,

Thanks for your reply.
I tried the suggestion but I get an error message.
It's possible that I have not explained my problem clearly.
Please the relevant part of my code.
When I get the AD search result for user with "surname", I display the user's CN and userPassword.
Instead of being shown the password, I get System.Byte[].
Apparently adObject.Proper ties["userPasswo rd"][0] is an object so can't convert to string.
Hope you're able to help.

Basicly trying to write code to email user's password to the user.

Thanks again,

Pere

DirectorySearch er adSearcherObjec t = new DirectorySearch er(adFolderObje ct);
adSearcherObjec t.SearchScope = SearchScope.Sub tree;
Console.Write(" Enter name to search for: ");
surname = Console.ReadLin e();

adSearcherObjec t.Filter = "(&(ObjectClass =user)(sn=" + surname + "))";

foreach (SearchResult adObject in adSearcherObjec t.FindAll())
{
count++;
found = true;
Console.WriteLi ne("CN={0}", adObject.Proper ties["CN"][0]);
PasswordString = System.Text.Enc oding.Default.G etString(adObje ct.Properties["userPasswo rd"][0]);
Console.WriteLi ne(PasswordStri ng);

"Dave Sexton" <dave@jwa[remove.this]online.com> wrote in message news:O2******** ******@TK2MSFTN GP03.phx.gbl...
Hi Pere,

System.Text.Enc oding.Default.G etString(bytes) ;

You can replace "Default" with any of ASCII, UTF32, UTF8, UTF7, Unicode and
BigEndianUnicod e if you'd like to match the appropriate encoding.

HTH

"Pere Raphael" <Pe**@community .nospam> wrote in message
news:uY******** ******@TK2MSFTN GP03.phx.gbl...
Hi all,

I am writng some code to read AD user properties but I am not having much
luck reading octet values. For example, there is a property userPassword
which returns System.Byte[].

When I use ADSIEDIT, I can see the value in the format 0x077 0x043 0x064
0x055 0x072 0x054 0x44 0x058 which I can convert by using Character Map.

Does anyone know how I can get the value of this property.

Regards,

Pere

PS: I am very new to C#


Jun 17 '06 #3
Have you visit here?
http://www.microsoft.com/technet/scr...s/default.mspx

chanmm
"Pere Raphael" <Pe**@community .nospam> wrote in message news:uE******** ******@TK2MSFTN GP04.phx.gbl...
Hi Dave,

Thanks for your reply.
I tried the suggestion but I get an error message.
It's possible that I have not explained my problem clearly.
Please the relevant part of my code.
When I get the AD search result for user with "surname", I display the user's CN and userPassword.
Instead of being shown the password, I get System.Byte[].
Apparently adObject.Proper ties["userPasswo rd"][0] is an object so can't convert to string.
Hope you're able to help.

Basicly trying to write code to email user's password to the user.

Thanks again,

Pere

DirectorySearch er adSearcherObjec t = new DirectorySearch er(adFolderObje ct);
adSearcherObjec t.SearchScope = SearchScope.Sub tree;
Console.Write(" Enter name to search for: ");
surname = Console.ReadLin e();

adSearcherObjec t.Filter = "(&(ObjectClass =user)(sn=" + surname + "))";

foreach (SearchResult adObject in adSearcherObjec t.FindAll())
{
count++;
found = true;
Console.WriteLi ne("CN={0}", adObject.Proper ties["CN"][0]);
PasswordString = System.Text.Enc oding.Default.G etString(adObje ct.Properties["userPasswo rd"][0]);
Console.WriteLi ne(PasswordStri ng);

"Dave Sexton" <dave@jwa[remove.this]online.com> wrote in message news:O2******** ******@TK2MSFTN GP03.phx.gbl...
Hi Pere,

System.Text.Enc oding.Default.G etString(bytes) ;

You can replace "Default" with any of ASCII, UTF32, UTF8, UTF7, Unicode and
BigEndianUnicod e if you'd like to match the appropriate encoding.

HTH

"Pere Raphael" <Pe**@community .nospam> wrote in message
news:uY******** ******@TK2MSFTN GP03.phx.gbl...
Hi all,

I am writng some code to read AD user properties but I am not having much
luck reading octet values. For example, there is a property userPassword
which returns System.Byte[].

When I use ADSIEDIT, I can see the value in the format 0x077 0x043 0x064
0x055 0x072 0x054 0x44 0x058 which I can convert by using Character Map.

Does anyone know how I can get the value of this property.

Regards,

Pere

PS: I am very new to C#


Jun 18 '06 #4
Hi Chanmm,

The User-Password attribute in AD is a write-only property. The password is
encrypted and stored. You cannot get decrypted text, instead, you can only
have this user reset password. Please check the following link for more
information about the User-Password attribute.

http://msdn.microsoft.com/library/de...us/adschema/ad
schema/a_userpassword. asp

Kevin Yu
Microsoft Online Community Support

=============== =============== =============== =============== =============== =
=============== ===========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =============== =============== =
=============== ===========

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
16010
by: John Hoffman | last post by:
Reading registry: .... RegistryKey rksub = rkey.OpenSubKey(s); String valstr = rksub.GetValueNames(); foreach (String vs in valstr) { String vstr = rksub.GetValue(vs).ToString(); OR String vstr = rksub.GetValue(vs);
2
1913
by: Claire | last post by:
This works ok in a new empty project. I write an empty string to a file. Looking at the file with a hex editor, there's a single byte of value zero. I expect this, it's utf8 encoding and this is the leading length byte. In my "real" project I have the following code. The first MessageBox tells me that the stream position is correct for...
3
3622
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows application, while I am doing for web. I can only find Image from web forms control and HTML control. This may be the root cause of my problem. For...
4
3277
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent...
9
6742
by: jeff M via .NET 247 | last post by:
I'm still having problems reading EBCDIC files. Currently itlooks like the lower range (0 to 127) is working. I have triedthe following code pages 20284, 20924, 1140, 37, 500 and 20127.By working I get the correct answer by taking the decimal valueand using that as an index to an array that will map to thecorrect EBCDIC value in hex. By larger...
2
1837
by: Mad Scientist Jr | last post by:
i'm trying to read a file byte by byte (and later alter the data and write it to a 2nd file byte by byte) and running into a problem where it seems to keep reading the same byte over and over again (an endless loop). i thought that BinaryReader.ReadByte advanced to the next byte? i had it time out after 1000 iterations, and keeps outputting...
3
3410
by: Zeke Zinzul | last post by:
Hi Guys & Geeks, What's the most elegant way of dealing with binary data and structures? Say I have this (which I actually do, a woo-hoo): struct Struct_IconHeader { byte width; byte height;
9
1814
by: Bill Woessner | last post by:
Suppose I have a structure, foo, which is a POD. I would like to read and write it to disk as follows: std::ofstream outs; foo bar; outs.write(reinterpret_cast<char*>(&bar), sizeof(foo)); .... std::ifstream ins; foo bar; ins.read(reinterpret_cas<char*>(&bar), sizeof(foo));
8
4348
by: Peter Bradley | last post by:
Hi, I wonder if anyone can help me out? I'm trying to implement an EPP (rfc4934 and rfc4930) client. So far I've managed to connect and authorise using an X509 Certificate. This should elicit a <greetingresponse from the server, and it's the reading of this response that is giving me a bit of grief. The response shoud be
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.