Page 4 of 4 <1234
Topic Options
#58060 - 2001-08-13 11:03 PM Re: Check for user account
Anonymous
Unregistered


How about using kix 2001?

; assign Domain or Computer name to $Domain
; assign user id to $UserID

$Result = getobject("WinNT://"+$Domain+"/"+$Userid+",user")
If @ERROR<>0
? "No such User (or Domain) "+$Domain+"/"+$Userid
Else
? "Yes they exist"
$Result=""
EndIf

Top
#58061 - 2001-08-13 11:22 PM Re: Check for user account
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yeah,

why doing all this painful and buggy shell ' bla rcmd blah... sh*t , when you can have it that simple ?

Jochen

_________________________



Top
#58062 - 2001-08-14 10:09 AM Re: Check for user account
Anonymous
Unregistered


This is unbelieveable!
We have three pages with text about this question and Mark typs one thing and it works.
And JPols not so adroit hè.

Top
#58063 - 2001-08-14 10:36 AM Re: Check for user account
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there are still ppl who aren't familiar with this ldap-stuff... or whatever it is called.
anyways, I've found rcmd very powerfull when you are mastering your server. example loading a database in and out and so on...
but what comes to finding usernames, kix2001 is much more simple.
the example mark gave shows how easy it can be.
and awinkel, I quess you didn't check my post on other page, when notifyid that it is done for kix2001? shawn (the code guru) made a udf which you can call like this:
userexist(\\server/username)

and it returns if user exist on that server or not. works for domain and wksta's too.

find it at http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=3&t=000190

_________________________
!

download KiXnet

Top
#58064 - 2001-08-15 12:56 AM Re: Check for user account
Anonymous
Unregistered


Yes, I have take a look at your post but I saw that I must install ADSI.
With Marks his option I don't have to do that.

Top
#58065 - 2001-08-14 01:10 PM Re: Check for user account
Anonymous
Unregistered


I'm very impressed, it works here as well and on machines where we've never installed ADSI either. All NT, all SP4 and above.
Top
#58066 - 2001-08-14 01:54 PM Re: Check for user account
Anonymous
Unregistered


I think we have the longest thread ever.
Top
#58067 - 2001-08-14 03:02 PM Re: Check for user account
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
awinkel, you are right, didn't think about compability.
and now we have a solution, short and working one!
_________________________
!

download KiXnet

Top
#58068 - 2001-09-05 01:18 PM Re: Check for user account
Anonymous
Unregistered


I have made a script with the code inside which I have from Mark Kochendorfer.
This is the code:
code:

; assign Domain or Computer name to $Domain
; assign user id to $UserID


$Result = getobject("WinNT://"+$Domain+"/"+$Userid+",user")
If @ERROR<>0
? "No such User (or Domain) "+$Domain+"/"+$Userid
Else
? "Yes they exist"
$Result=""
EndIf



This works perfect on my W2K pro system but not on the NT4.0 PDC SP6a.
Anyone any idea why?

[ 05 September 2001: Message edited by: awinkel ]

Top
#58069 - 2001-09-05 02:15 PM Re: Check for user account
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
HI All,

thought i had to say something here...

When you start using ADSI in combination with Kix2K the following rules apply:

The script must be run on a machine that is either Windows 2K or up OR an NT4 machine that has ADSI installed (get it at MS).

Also, when you are targeting NT4 machines with ADSI, you must use the WinNT: provider, you can only use the LDAP: provider when you are targeting W2K machines (Active Directory)

As long as you are using the WinNT provider you don't need any prereqs on them servers.

There are some other problems to be overcome when using ADSI, i am working in an environment of 110+ NT4 domains, all remote, no trust relations and without WINS replication. hence to succesfully connect to a remote server i first need to check one of the possible release levels which indicates the passwords to use, i have done this through a small piece of code that reads a ini file with some of the combinations and try and map to an administrative share.

code:
 

$connstatus = "not connected"
for each $adminstring in split(readprofilestring($inifile,"admins",""),chr(10))
if $connstatus <> "connected"
if $adminstring

$tempstring = split($adminstring, ";")
$adminname = $tempstring[0]
$adminpw = $tempstring[1]
$admindesc = $tempstring[2]
use x: "\\$homeserver\c$" /user:$adminname /password:$adminpw
select
case @error = 0
$connuser = $adminname
$connpw = $adminpw
$connstatus = "connected"
case @error = 53
? "Error connecting to " + $domain + "."
return
endselect
endif
endif
next

net use x: /delete


i don't use that share to give me the proper ADSI rights, i prefer a connection with adsi passing credentials.

Another problem is the lack of WINS, as adsi tries to connect to a domain, it looks for the Netbios 1B and 1C entries. Normally with WINS replicating all your domains, this is no problem. to do it with an LMHOSTS entry you need a double entry like this (Servername = Myserver and domainname = Mydomain, ip = 1.2.3.4, Myserver is the PDC for Mydomain)

1.2.3.4 Myserver #PRE #DOM:Mydomain
1.2.3.4 "Mydomain \0x1b" #PRE

NOTE the board corrupts formatting, but between Mydomain and \0x1b there should be enough spacing (no tabs!!) so that the \ is the 16th character (IMPORTANT !!) this has to do with Netbios being 16 bytes long, 15 chars for the name and one byte for the type (1B, 1C, 03, 00 etc)

Now you can use ADSI to connect to Mydomain without any problems. to use ADSI for passing credentials use :

$root = Getobject ("WinNT:")
$dm = $root.opendsobject("WinNT://$Mydomain,domain","$connuser","$connpw",1)

where $Mydoamin is the domain to connect to and $connuser is administrative useraccount and $connpw is the password for that account.

for all other tricks concerning checking of,modifying and creating users pls refer to other recent posts that covered this.


Hope this clarifies a little on ADSI.

Ciao,
MvdW

(ps i learned it all from Shawn ..
)

[ 05 September 2001: Message edited by: mvdw ]

_________________________
rgrds, Maarten

Top
#58070 - 2001-09-05 06:06 PM Re: Check for user account
Anonymous
Unregistered


Thanks in advance for make this clear for me.
Tomorrow when I'm at work I try this.

Top
Page 4 of 4 <1234


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.106 seconds in which 0.084 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org