logonuser api

  • Thread starter Thread starter plmanikandan
  • Start date Start date
P

plmanikandan

Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem
 
Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem

If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0, the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.


[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
....

Willy.
 
Thanks Willy Denoyette for your immediate reply.
I am already using NetUserChangePassword in my program,but i forget to
trap the error 1327.thanks for your valuable information.Is there any
chance for the password corruption if anything goes wrong while
executing NetUserChangePassword call.Is it possible to use some other
services to check windows username,password

Regards,
mani
Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem

If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0, the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.


[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
...

Willy.
 
No framework solution unless you are using v2.0 of the framework.

Willy.


Thanks Willy Denoyette for your immediate reply.
I am already using NetUserChangePassword in my program,but i forget to
trap the error 1327.thanks for your valuable information.Is there any
chance for the password corruption if anything goes wrong while
executing NetUserChangePassword call.Is it possible to use some other
services to check windows username,password

Regards,
mani
Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem

If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain
password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0,
the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.


[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine
name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
...

Willy.
 
Back
Top