473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

User Must Change Password At Next Logon - LDAP And .NET

Ram
Hey,
I'v managed to set the "User Must Change Password At Next Logon" flag on the
LDAP protocol,
Using the - "pwdLastSet" property - by setting it to - "0" (for on) or -
"-1" (for off).
The problem is, I dont know how to check what's the current status of this
user -
When I try and read this property from the user's DirectoryEntry,
I get a "System.ComObject" object, and I cant get any data from this object.
Does Anyone has an idea what object is this, or how can I get this value
otherwise?
Thanks ahead

--Ram
Nov 16 '05 #1
5 20216
The PropertyValueCollection element 0 contains a COM IDispatch Pointer
(__ComObject), use late binding to retrieve the HighPart
and LowPart properties, of the LastLogon Date.
Combine both into a long and pass it to FromFileTime.

Add a reference to activeds.tlb
Try this:

Dim de As DirectoryEntry = _
New DirectoryEntry("LDAP://xxxx/CN=Users,DC=xx,DC=yy,DC=zz")
Dim mySearcher as DirectorySearcher = new DirectorySearcher(de)
mySearcher.Filter = "(samAccountName=administrator)"
mySearcher.PropertiesToLoad.Add("samAccountName")
mySearcher.PropertiesToLoad.Add("lastLogon")
Dim myResult as SearchResult
myResult = mySearcher.FindOne()
de = new DirectoryEntry(myResult.Path)
Dim pcoll as PropertyCollection = de.Properties
Dim li as LargeInteger
Dim oli as object = pcoll("lastLogon")(0) ' Set object reference to
ILargeInteger
Dim lDate as Long = (oli.HighPart * &h100000000) + oli.LowPart 'Combine
LowPart and HighPart
Console.WriteLine("DATE = {0:D}" ,DateTime.FromFileTime(lDate)) 'Convert
from FileTime foramt to DateTime
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Ram" <ni***@bezeqint.net> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hey,
I'v managed to set the "User Must Change Password At Next Logon" flag on the LDAP protocol,
Using the - "pwdLastSet" property - by setting it to - "0" (for on) or -
"-1" (for off).
The problem is, I dont know how to check what's the current status of this
user -
When I try and read this property from the user's DirectoryEntry,
I get a "System.ComObject" object, and I cant get any data from this object. Does Anyone has an idea what object is this, or how can I get this value
otherwise?
Thanks ahead

--Ram

Nov 16 '05 #2
BTW, your clock is 1 hour ahead. Please check this!

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Ram" <ni***@bezeqint.net> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hey,
I'v managed to set the "User Must Change Password At Next Logon" flag on the LDAP protocol,
Using the - "pwdLastSet" property - by setting it to - "0" (for on) or -
"-1" (for off).
The problem is, I dont know how to check what's the current status of this
user -
When I try and read this property from the user's DirectoryEntry,
I get a "System.ComObject" object, and I cant get any data from this object. Does Anyone has an idea what object is this, or how can I get this value
otherwise?
Thanks ahead

--Ram

Nov 16 '05 #3
Ram
Hey Tamir,
Thanks for your replies (both in this thread and in the past ones)!
The - "LowPart" and "HighPart" methods work great,
But the thing is, when I create a new user, it gets - by default - the "Must
Change Password At Next Logon" flag.
And when I check the LowPart or HighPart at this time, they both equles to -
0.
Are there some other methods/properties for this object?
Thanks again,

--Ram
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
The PropertyValueCollection element 0 contains a COM IDispatch Pointer
(__ComObject), use late binding to retrieve the HighPart
and LowPart properties, of the LastLogon Date.
Combine both into a long and pass it to FromFileTime.

Add a reference to activeds.tlb
Try this:

Dim de As DirectoryEntry = _
New DirectoryEntry("LDAP://xxxx/CN=Users,DC=xx,DC=yy,DC=zz")
Dim mySearcher as DirectorySearcher = new DirectorySearcher(de)
mySearcher.Filter = "(samAccountName=administrator)"
mySearcher.PropertiesToLoad.Add("samAccountName")
mySearcher.PropertiesToLoad.Add("lastLogon")
Dim myResult as SearchResult
myResult = mySearcher.FindOne()
de = new DirectoryEntry(myResult.Path)
Dim pcoll as PropertyCollection = de.Properties
Dim li as LargeInteger
Dim oli as object = pcoll("lastLogon")(0) ' Set object reference to
ILargeInteger
Dim lDate as Long = (oli.HighPart * &h100000000) + oli.LowPart 'Combine
LowPart and HighPart
Console.WriteLine("DATE = {0:D}" ,DateTime.FromFileTime(lDate)) 'Convert
from FileTime foramt to DateTime
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Ram" <ni***@bezeqint.net> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hey,
I'v managed to set the "User Must Change Password At Next Logon" flag on

the
LDAP protocol,
Using the - "pwdLastSet" property - by setting it to - "0" (for on) or -
"-1" (for off).
The problem is, I dont know how to check what's the current status of this user -
When I try and read this property from the user's DirectoryEntry,
I get a "System.ComObject" object, and I cant get any data from this

object.
Does Anyone has an idea what object is this, or how can I get this value
otherwise?
Thanks ahead

--Ram


Nov 16 '05 #4
After you create the new user you need to set the password. Assuming your
DirectoryEntry variable representing the user is called "de" you would
simple do:

de.Invoke("SetPassword", "userinitialpassword");

Also note that if the domain is set to a higher security than default you
will need to create the user, set the password and THEN set the
userAccountControl attribute to enable the account (high security will not
allow you to enable a user account with blank passwords)

Arild

"Ram" <ni***@bezeqint.net> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
Hey Tamir,
Thanks for your replies (both in this thread and in the past ones)!
The - "LowPart" and "HighPart" methods work great,
But the thing is, when I create a new user, it gets - by default - the "Must Change Password At Next Logon" flag.
And when I check the LowPart or HighPart at this time, they both equles to - 0.
Are there some other methods/properties for this object?
Thanks again,

--Ram
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
The PropertyValueCollection element 0 contains a COM IDispatch Pointer
(__ComObject), use late binding to retrieve the HighPart
and LowPart properties, of the LastLogon Date.
Combine both into a long and pass it to FromFileTime.

Add a reference to activeds.tlb
Try this:

Dim de As DirectoryEntry = _
New DirectoryEntry("LDAP://xxxx/CN=Users,DC=xx,DC=yy,DC=zz")
Dim mySearcher as DirectorySearcher = new DirectorySearcher(de)
mySearcher.Filter = "(samAccountName=administrator)"
mySearcher.PropertiesToLoad.Add("samAccountName")
mySearcher.PropertiesToLoad.Add("lastLogon")
Dim myResult as SearchResult
myResult = mySearcher.FindOne()
de = new DirectoryEntry(myResult.Path)
Dim pcoll as PropertyCollection = de.Properties
Dim li as LargeInteger
Dim oli as object = pcoll("lastLogon")(0) ' Set object reference to
ILargeInteger
Dim lDate as Long = (oli.HighPart * &h100000000) + oli.LowPart 'Combine
LowPart and HighPart
Console.WriteLine("DATE = {0:D}" ,DateTime.FromFileTime(lDate)) 'Convert
from FileTime foramt to DateTime
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Ram" <ni***@bezeqint.net> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hey,
I'v managed to set the "User Must Change Password At Next Logon" flag on
the
LDAP protocol,
Using the - "pwdLastSet" property - by setting it to - "0" (for on)
or - "-1" (for off).
The problem is, I dont know how to check what's the current status of

this user -
When I try and read this property from the user's DirectoryEntry,
I get a "System.ComObject" object, and I cant get any data from this

object.
Does Anyone has an idea what object is this, or how can I get this value otherwise?
Thanks ahead

--Ram



Nov 16 '05 #5
Ram
Thanks Arild - when I set the password before I Commit Changes, the - "Must
Change Password At Next Logon" flag is set to off!
Thanks for both of you for your help!

--Ram
"Arild Bakken" <ar*****@hotmail.com> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
After you create the new user you need to set the password. Assuming your
DirectoryEntry variable representing the user is called "de" you would
simple do:

de.Invoke("SetPassword", "userinitialpassword");

Also note that if the domain is set to a higher security than default you
will need to create the user, set the password and THEN set the
userAccountControl attribute to enable the account (high security will not
allow you to enable a user account with blank passwords)

Arild

"Ram" <ni***@bezeqint.net> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
Hey Tamir,
Thanks for your replies (both in this thread and in the past ones)!
The - "LowPart" and "HighPart" methods work great,
But the thing is, when I create a new user, it gets - by default - the "Must
Change Password At Next Logon" flag.
And when I check the LowPart or HighPart at this time, they both equles

to -
0.
Are there some other methods/properties for this object?
Thanks again,

--Ram
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
The PropertyValueCollection element 0 contains a COM IDispatch Pointer
(__ComObject), use late binding to retrieve the HighPart
and LowPart properties, of the LastLogon Date.
Combine both into a long and pass it to FromFileTime.

Add a reference to activeds.tlb
Try this:

Dim de As DirectoryEntry = _
New DirectoryEntry("LDAP://xxxx/CN=Users,DC=xx,DC=yy,DC=zz")
Dim mySearcher as DirectorySearcher = new DirectorySearcher(de)
mySearcher.Filter = "(samAccountName=administrator)"
mySearcher.PropertiesToLoad.Add("samAccountName")
mySearcher.PropertiesToLoad.Add("lastLogon")
Dim myResult as SearchResult
myResult = mySearcher.FindOne()
de = new DirectoryEntry(myResult.Path)
Dim pcoll as PropertyCollection = de.Properties
Dim li as LargeInteger
Dim oli as object = pcoll("lastLogon")(0) ' Set object reference to
ILargeInteger
Dim lDate as Long = (oli.HighPart * &h100000000) + oli.LowPart 'Combine LowPart and HighPart
Console.WriteLine("DATE = {0:D}" ,DateTime.FromFileTime(lDate)) 'Convert from FileTime foramt to DateTime
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Ram" <ni***@bezeqint.net> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
> Hey,
> I'v managed to set the "User Must Change Password At Next Logon"
flag on the
> LDAP protocol,
> Using the - "pwdLastSet" property - by setting it to - "0" (for on) or - > "-1" (for off).
> The problem is, I dont know how to check what's the current status
of
this
> user -
> When I try and read this property from the user's DirectoryEntry,
> I get a "System.ComObject" object, and I cant get any data from this
object.
> Does Anyone has an idea what object is this, or how can I get this

value > otherwise?
> Thanks ahead
>
> --Ram
>
>



Nov 16 '05 #6

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

Similar topics

2
by: Frederick | last post by:
Hi, I am using ADAM as my Data Store for my web application and although this seems to be fine when using windows authentication with my local account when I try to create a new user and use...
1
by: Ram | last post by:
Hey, I'v managed to set the "User Must Change Password At Next Logon" flag on the LDAP protocol, Using the - "pwdLastSet" property - by setting it to - "0" (for on) or - "-1" (for off). The...
8
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
1
by: moi | last post by:
Hello, I have make a Active Directory Membership to change the user password in the active directory with ASP.NET2 after a logo page, and it works fine. BUT i add this code when the password is...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
10
by: Jeff Williams | last post by:
How can I get a list of the Groups both Local and Domain groups a User belongs to.
9
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
8
by: Michael Howes | last post by:
I have some code that manages local user logins. When I create a new user I want to set the password to expire every x days and the number of failed login attempts before the account is...
3
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, we've got a strange problem here: We've created an ASP.NET 2.0 web application using Membership.ValidateUser() to manually authenticate users with our website. The problem is: If the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.