logonuser api

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
 
W

Willy Denoyette [MVP]

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.
 
P

plmanikandan

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.
 
W

Willy Denoyette [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top